Bug 17981: Better error handling
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 24 Jan 2017 16:13:07 +0000 (17:13 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 12 Apr 2018 13:51:50 +0000 (10:51 -0300)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/preview_letter.tt
svc/letters/preview

index f7aea70..4bde77d 100644 (file)
@@ -12,6 +12,9 @@
                     [% CASE 'preview_not_available' %]Preview is not available for letters '[% m.letter_code %]'.
                     [% CASE 'not_checked_in_yet' %]Do not forget that the issue has not been checked in yet.
                     [% CASE 'not_checked_out_yet' %]Do not forget that the issue has not been checked out yet.
+                    [% CASE 'no_checkout' %]This item is not checked out.
+                    [% CASE 'no_item_or_no_patron' %]The item or the patron does not exist.
+                    [% CASE 'no_hold' %]No hold is placed by this patron on this bibliographic record.
                     [% CASE %][% m.code %]
                     [% END %]
                 </div>
@@ -28,7 +31,7 @@
                 </fieldset>
             [% END %]
 
-            [% IF tt_content %]
+            [% IF rendered_tt_message %]
                 <fieldset class="brief">
                     <legend>Converted version</legend>
                     <pre>[% tt_content | html %]</pre>
@@ -41,7 +44,7 @@
             [% END %]
         </div>
 
-        [% IF tt_content %]
+        [% IF rendered_tt_message %]
             [% IF messages_are_similar %]
                 <div class="dialog message">The generated notices are exactly the same!</div>
             [% ELSE %]
index d517398..809ee72 100644 (file)
@@ -169,7 +169,8 @@ if ( $code eq 'CHECKIN' ) {
         push @messages, { code => 'not_checked_in_yet', type => 'message' };
     }
     else {
-        warn "No checkout";
+        push @messages, { code => 'no_checkout', type => 'alert' };
+        $letter_params = {};
     }
 }
 elsif ( $code eq 'CHECKOUT' ) {
@@ -193,7 +194,8 @@ elsif ( $code eq 'CHECKOUT' ) {
         push @messages, { code => 'not_checked_out_yet', type => 'message' };
     }
     else {
-        warn "No item or no patron";
+        push @messages, { code => 'no_item_or_no_patron', type => 'alert' };
+        $letter_params = {};
     }
 }
 elsif ( $code eq 'HOLD_SLIP' ) {
@@ -212,11 +214,11 @@ elsif ( $code eq 'HOLD_SLIP' ) {
         };
     }
     else {
-        warn "No hold placed by this patron on this bibliographic record.";
+        push @messages, { code => 'no_hold', type => 'alert' };
+        $letter_params = {};
     }
 }
 else {
-    warn "Preview for letter code $code is not available";
     push @messages, { type => 'alert', code => 'preview_not_available', letter_code => $code, };
 }