diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-20 21:36:16 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-20 21:36:16 +1300 |
commit | f04d420b323a324233c48d525254f1211afc0771 (patch) | |
tree | 2c4e49bf9dea236dbc069391f57ec5e0b64032e4 /web/app/Application.js | |
parent | 2bb63a0b1c82c42c0d13614c5a67521130165368 (diff) | |
download | trackermap-server-f04d420b323a324233c48d525254f1211afc0771.tar.gz trackermap-server-f04d420b323a324233c48d525254f1211afc0771.tar.bz2 trackermap-server-f04d420b323a324233c48d525254f1211afc0771.zip |
Update javascript API error handling
Diffstat (limited to 'web/app/Application.js')
-rw-r--r-- | web/app/Application.js | 30 |
1 files changed, 8 insertions, 22 deletions
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); - } - } - }; } }); |