From 68f63ff60248e00c5f745b0bf981728e05945b20 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 8 Jun 2019 13:57:05 -0500 Subject: [PATCH] Bug 23075: Better error handling in Mana config Currently, if you input an incorrect mana service URL in your config (http rather than https for example) the error message you are given is the direct output of a failed json parse. We should be able to catch such failures and display a more meaningful error to the end user. This patch makes it display a more friendly message. Signed-off-by: David Nind Signed-off-by: Nick Clemens --- Koha/SharedContent.pm | 7 +++++++ koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm index 7145e950c3..d2129d965e 100644 --- a/Koha/SharedContent.pm +++ b/Koha/SharedContent.pm @@ -52,6 +52,13 @@ sub process_request { my $response = $userAgent->request($mana_request); + if ( $response->code != 200 ) { + return { + code => $response->code, + msg => $response->message, + }; + } + eval { $result = from_json( $response->decoded_content, { utf8 => 1} ); }; $result->{code} = $response->code; if ( $@ ){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt index 11d4e6c196..df8599e64e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt @@ -19,7 +19,7 @@
[% IF result.code != 201 && result.msg %] [% END %] -- 2.11.0