 +            # Because of staff mistakes, patrons are sometimes registered with existing cardnumber
 +            # without checking if they allready exist in NL.
 +            # We set syncstatus to 'edited', so that it might be correctly synced next time.
-+            # The lastsync value is arbritary, and will be corrected if NL complains
-+            $sync->update( { 'syncstatus' => 'edited', 'lastsync' => `date +"%Y-%m-%dT%T"` } );
++            # The lastsync value is arbritary, and will be corrected on next iteration
++            $sync->update( { 'syncstatus' => 'edited', 'lastsync' => '2016-11-12T14:05:22' } );
 +        } elsif ($cause =~ /lnr finnes ikke i registeret/) {
 +            # Make sure syncstatus is 'new'
 +            $sync->update( { 'syncstatus' => 'new' } );

 )] );
 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.
