From 68e5d95a8c167060b56c8bd01b3073bdf6c739f1 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 13 Jan 2014 09:09:06 +1300 Subject: [PATCH] Adding error handling for CheckIn --- lib/NCIP/Handler/CheckInItem.pm | 10 +++++----- templates/problem.tt | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/NCIP/Handler/CheckInItem.pm b/lib/NCIP/Handler/CheckInItem.pm index 88cd8bc..2656f68 100644 --- a/lib/NCIP/Handler/CheckInItem.pm +++ b/lib/NCIP/Handler/CheckInItem.pm @@ -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 { diff --git a/templates/problem.tt b/templates/problem.tt index 4da5935..6c89a82 100644 --- a/templates/problem.tt +++ b/templates/problem.tt @@ -5,11 +5,18 @@ - [% processingerrortype %] + + [% SWITCH processingerrortype %] + [% CASE 'BadBarcode' %] + We could not find an item with that barcode + [% CASE 'NotIssued' %] + The item is not on loan + [% END %] + [% processingerrorelement %] - [% processingerrorvalue %] + [% barcode %] [% error_detail %] -- 2.11.0