diff options
Diffstat (limited to 'web/app/Application.js')
-rw-r--r-- | web/app/Application.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index e710b7ea2..83ca9e860 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -76,5 +76,24 @@ Ext.define('Traccar.Application', { getPreference: function (key, defaultValue) { return this.getUser().get(key) || this.getServer().get(key) || defaultValue; + }, + + 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); + } + handler.call(scope, options, success, response); + } else { + if (response.statusText) { + Ext.Msg.alert(Strings.errorTitle, response.statusText); + } else { + Ext.Msg.alert(Strings.errorTitle, response.status.toString()); // TODO: text message + } + } + } } }); |