From adb30fb8a0347ab6ff391238a8bd1ce4b6931fcd 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 Signed-off-by: Martin Renvoize --- Koha/SharedContent.pm | 7 +++++++ .../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.39.5