 +        return ($response, 1);
 +    }
 +
++    if ($cause =~ /fnr_hash mangler/) {
++        # Missing required personal number. Turn of NL-sync
++        $sync->update( { 'sync' => 0 } );
++        return ($response, 1);
++    }
++
 +    # Something is wrong but we don't know how to handle it, so no point
 +    # in trying again.
 +    return ($response, 1);
  }
 
  =head2 NLGetChanged
-@@ -426,7 +519,7 @@ sub NLUpdateHashedPIN {
+@@ -426,7 +524,7 @@ sub NLUpdateHashedPIN {
      my $borrowersync = Koha::Database->new->schema->resultset('BorrowerSync')->find({
          'synctype'       => 'norwegianpatrondb',
          'borrowernumber' => $borrowernumber,

+    # Handle error special cases
+    my $cause = $response->result->{'melding'};
+    return ($response, 1) unless $cause;
+    say $cause;
+
+    if ($cause =~ /lnr finnes allerede i registeret/) {
+        # Because of staff mistakes, patrons are sometimes registered with existing cardnumber

 )] );
 Exporter::export_ok_tags('all');

@@ -237,33 +238,130 @@ sub NLSync {

     my $cardnumber = SOAP::Data->name( 'lnr' => $patron->cardnumber );

