From bad65780bc8ab0d3ccbb09b5a6fd954b04cfa802 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 13 Feb 2014 18:47:19 +0000 Subject: [PATCH] Register a JSON handler to show error responses as error message instead of losing them. --- phpgwapi/js/jsapi/egw_message.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpgwapi/js/jsapi/egw_message.js b/phpgwapi/js/jsapi/egw_message.js index 4d98c8e6cd..7b72561a25 100644 --- a/phpgwapi/js/jsapi/egw_message.js +++ b/phpgwapi/js/jsapi/egw_message.js @@ -29,6 +29,16 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) var error_reg_exp; var on_click_remove_installed = false; + // Register an 'error' plugin, displaying using the message system + this.registerJSONPlugin(function(type, res, req) { + if (typeof res.data == 'string') + { + egw.message(res.data,'error'); + return true; + } + throw 'Invalid parameters'; + }, null, 'error'); + return { /** * Display an error or regular message