X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/78644811ca0c6042212788dc67add42bc41fb74c..e024b596f2a1b5346fd22837aec0116c05f17ed9:/platforma/static/js/app.js diff --git a/platforma/static/js/app.js b/platforma/static/js/app.js index fde15393..8dae56e4 100644 --- a/platforma/static/js/app.js +++ b/platforma/static/js/app.js @@ -180,6 +180,31 @@ Editor.Object = Class.extend({ } }); +// Handle JSON error responses in uniform way +function parseXHRError(response) +{ + var message = "" + try { + var json = $.evalJSON(response.responseText); + + if(json.reason == 'xml-parse-error') { + message = json.message.replace(/(line\s+)(\d+)(\s+)/i, + "$1$2$3"); + + message = message.replace(/(line\s+)(\d+)(\,\s*column\s+)(\d+)/i, + "$1$2$3$4"); + } + else { + message = json.message || json.reason || "Nieznany błąd :(("; + } + + } catch(e) { + // not a valid JSON response + message = response.statusText; + } + return message; +} + Editor.Object._lastGuid = 0; -var panels = []; +var panels = []; \ No newline at end of file