improved exception handling in frontend

This commit is contained in:
Steffen Vogel 2011-03-16 12:13:08 +01:00
parent ca92eaa5e7
commit 79db3f6c19

View file

@ -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);
}
}
});