  =head2 _soap_to_koha_patron
 
  Convert a SOAP object of type "Laaner" into a hash that can be sent to AddMember or ModMember.
-@@ -635,13 +705,13 @@ sub _koha_patron_to_soap {
+@@ -635,13 +698,13 @@ sub _koha_patron_to_soap {
              SOAP::Data->name( 'fnr_hash'    => $patron_attributes->{ 'fnr' } )->type( 'string' )->type( 'string' ),
              SOAP::Data->name( 'navn'        => $patron->surname . ', ' . $patron->firstname    )->type( 'string' ),
              SOAP::Data->name( 'sist_endret' => $sync->lastsync      )->type( 'string' ),

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

@@ -261,6 +262,58 @@ sub NLSync {
         $sync->update( { 'syncstatus' => 'synced' } );
         # Update the 'synclast' attribute with the "server time" ("server_tid") returned by the method
         $sync->update( { 'lastsync' => $response->{'server_tid'} } );
+    } else {
+        # Handle error special cases
+        my $cause = $response->result->{'melding'};

+            $sync->update( { 'lastsync' => substr($cause, $i + 14, 19) } );
+        } elsif ($cause =~ /Oppdaterte felt/) {
+            # The request was succesfull, even if not reported with status=1
+            $sync->update( { 'syncstatus' => 'synced', 'lastsync' => $response->{'server_tid'} } );
+        } elsif ($cause =~ /Person med gitt fnr finnes allerede i registeret med nummer/) {
+            # Patron was registered as new, withouth checking for existing patron in NL using the given fnr
+            # We attemt to sync the new cardnumber to NL.
