From f04d420b323a324233c48d525254f1211afc0771 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 20 Dec 2015 21:36:16 +1300 Subject: Update javascript API error handling --- web/app/Application.js | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'web/app/Application.js') diff --git a/web/app/Application.js b/web/app/Application.js index 5cc192686..fc4344a08 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -20,7 +20,6 @@ Ext.define('Traccar.Application', { requires: [ 'Traccar.Style', - 'Traccar.ErrorManager', 'Traccar.AttributeFormatter' ], @@ -79,33 +78,20 @@ Ext.define('Traccar.Application', { }, showError: function (response) { + var data; if (Ext.isString(response)) { Ext.Msg.alert(Strings.errorTitle, response); + } else if (response.responseText) { + data = Ext.decode(response.responseText); + if (data.details) { + Ext.Msg.alert(Strings.errorTitle, data.details); + } else { + Ext.Msg.alert(Strings.errorTitle, data.message); + } } else if (response.statusText) { Ext.Msg.alert(Strings.errorTitle, response.statusText); } else { Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection); } - }, - - getErrorHandler: function (scope, handler) { - return function (options, success, response) { - var result; - if (success) { - result = Ext.decode(response.responseText); - if (!result.success) { - Ext.Msg.alert(Strings.errorTitle, result.error); - } - if (handler) { - handler.call(scope, options, success, response); - } - } else { - if (response.statusText) { - Ext.Msg.alert(Strings.errorTitle, response.statusText); - } else { - Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection); - } - } - }; } }); -- cgit v1.2.3