Adding error handling for CheckIn
authorChris Cormack <chrisc@catalyst.net.nz>
Sun, 12 Jan 2014 20:09:06 +0000 (09:09 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Sun, 12 Jan 2014 20:09:06 +0000 (09:09 +1300)
lib/NCIP/Handler/CheckInItem.pm
templates/problem.tt

index 88cd8bc..2656f68 100644 (file)
@@ -24,20 +24,20 @@ sub handle {
     my $xmldoc = shift;
     if ($xmldoc) {
         my $root = $xmldoc->documentElement();
-        my $userid =
-          $root->findnodes('CheckInItem/UniqueUserId/UserIdentifierValue');
         my $itemid =
           $root->findnodes('CheckInItem/UniqueItemId/ItemIdentifierValue');
         my @elements = $root->findnodes('CheckInItem/ItemElementType/Value');
 
         # checkin the item
-        my $checkin = $self->ils->checkin( $userid, $itemid );
+        my $checkin = $self->ils->checkin( $itemid );
         my $output;
         my $vars;
         $vars->{'messagetype'} = 'CheckInItemResponse';
-
+        $vars->{'barcode'} = $itemid;
         if ( !$checkin->{success} ) {
-
+            $var->{'processingerror'} = 1;
+            $var->{'processingerrortype'} = $checkin->{'messages'};
+            $var->{'processingerrorelement'} = 'UniqueItemIdentifier';
             $output = $self->render_output( 'problem.tt', $vars );
         }
         else {
index 4da5935..6c89a82 100644 (file)
@@ -5,11 +5,18 @@
     <Problem>
       <ProcessingError>
         <ProcessingErrorType>
-          <Value>[% processingerrortype %]</Value>
+          <Value>
+          [% SWITCH processingerrortype %]
+            [% CASE 'BadBarcode' %]
+              We could not find an item with that barcode
+            [% CASE 'NotIssued' %]
+              The item is not on loan
+            [% END %]
+          </Value>
         </ProcessingErrorType>
         <ProcessingErrorElement>
           <ElementName>[% processingerrorelement %]</ElementName>
-          <ProcessingErrorValue>[% processingerrorvalue %]</ProcessingErrorValue>
+          <ProcessingErrorValue>[% barcode %]</ProcessingErrorValue>
         </ProcessingErrorElement>
       </ProcessingError> 
       <ProblemDetail>[% error_detail %]</ProblemDetail>