improved exception handling in frontend
This commit is contained in:
parent
ca92eaa5e7
commit
79db3f6c19
1 changed files with 14 additions and 2 deletions
|
@ -32,8 +32,20 @@ vz.load = function(args) {
|
|||
url: this.options.backendUrl,
|
||||
dataType: 'json',
|
||||
error: function(xhr) {
|
||||
json = JSON.parse(xhr.responseText);
|
||||
vz.wui.dialogs.error(xhr.statusText, json.exception.message, xhr.status);
|
||||
try {
|
||||
if (xhr.getResponseHeader('Content-type') == 'application/json') {
|
||||
var json = JSON.parse(xhr.responseText);
|
||||
|
||||
if (json.exception) {
|
||||
throw new Exception(json.exception.type, json.exception.message, (json.exception.code) ? json.exception.code : xhr.status);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception(xhr.statusText, 'Unknown backend response', xhr.status)
|
||||
}
|
||||
catch (e) {
|
||||
vz.wui.dialogs.exception(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue