From: Marcin Haba Date: Sat, 18 Aug 2018 18:48:27 +0000 (+0200) Subject: baculum: Improve error handling in web part X-Git-Tag: Release-9.2.2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f059eb51228f4a321316e9f2631b4625fec3084;p=thirdparty%2Fbacula.git baculum: Improve error handling in web part --- diff --git a/gui/baculum/protected/Web/Class/BaculumAPIClient.php b/gui/baculum/protected/Web/Class/BaculumAPIClient.php index ab11e4592..1721c08a5 100644 --- a/gui/baculum/protected/Web/Class/BaculumAPIClient.php +++ b/gui/baculum/protected/Web/Class/BaculumAPIClient.php @@ -465,11 +465,15 @@ class BaculumAPIClient extends WebModule { } if ($show_error === true && $resource->error != 0) { - $url = $this->Service->constructUrl('BaculumError', (array)$resource, false); - header("Location: $url"); - // write all logs before exiting, otherwise they will be lost - $this->getModule('log')->collectLogs(null); - exit(); + $headers = $this->Request->getHeaders(CASE_UPPER); + if (!isset($headers['X-REQUESTED-WITH']) || $headers['X-REQUESTED-WITH'] !== 'XMLHttpRequest') { + // it is non-ajax request - redirect it to error page + $url = $this->Service->constructUrl('BaculumError', (array)$resource, false); + header("Location: $url"); + // write all logs before exiting, otherwise they will be lost + $this->getModule('log')->collectLogs(null); + exit(); + } } $this->Application->getModule('logging')->log( diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index ef485bb2b..233e33fa3 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index fe3bbd932..612aa9580 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -1828,3 +1828,10 @@ msgstr "Log order" msgid "Close Menu" msgstr "Close Menu" + +msgid "Error code:" +msgstr "Error code:" + +msgid "Message:" +msgstr "Message:" + diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index b2e7a7915..2015cf226 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index ddea82e88..b6e6227c1 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -1579,3 +1579,10 @@ msgstr "Log order" msgid "Close Menu" msgstr "Close Menu" + +msgid "Error code:" +msgstr "Error code:" + +msgid "Message:" +msgstr "Message:" + diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index c3942485a..48c7918df 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index ac06df749..c7f3fb67c 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -1835,3 +1835,9 @@ msgstr "Kolejność dziennika" msgid "Close Menu" msgstr "Zamknij Menu" + +msgid "Error code:" +msgstr "Kod błędu:" + +msgid "Message:" +msgstr "Wiadomość:" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 32c34f482..a7ec95d03 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index f58d1fc27..695c9fed3 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -1843,3 +1843,10 @@ msgstr "Ordenar log" msgid "Close Menu" msgstr "Fechar menu" + +msgid "Error code:" +msgstr "Error code:" + +msgid "Message:" +msgstr "Message:" + diff --git a/gui/baculum/protected/Web/Layouts/Main.tpl b/gui/baculum/protected/Web/Layouts/Main.tpl index 042c89827..16b87c0fa 100644 --- a/gui/baculum/protected/Web/Layouts/Main.tpl +++ b/gui/baculum/protected/Web/Layouts/Main.tpl @@ -38,6 +38,21 @@
+