- Catch save exception is the object is not JSON

This commit is contained in:
Paulo Gustavo Veiga 2012-09-16 21:08:35 -03:00
parent 7b1574150a
commit 6badd972b0

View File

@ -46,7 +46,13 @@ mindplot.RESTPersistenceManager = new Class({
}, },
onFailure:function (xhr) { onFailure:function (xhr) {
var responseText = xhr.responseText; var responseText = xhr.responseText;
events.onError(JSON.decode(responseText)); var error = null;
try {
error = JSON.decode(responseText);
} catch (e) {
throw "Unexpected error saving. Error response is not json object:" + responseText;
}
events.onError(error);
}, },
headers:{"Content-Type":"application/json", "Accept":"application/json"}, headers:{"Content-Type":"application/json", "Accept":"application/json"},
emulation:false, emulation:false,