From: arno Date: Fri, 18 Mar 2011 12:35:42 +0000 (+0100) Subject: warns user when there is a server side error X-Git-Tag: v0.3~19 X-Git-Url: https://dev.renevier.net/?p=syj.git;a=commitdiff_plain;h=bd3de07b5ee90369741ef197230b4744f33eeda1 warns user when there is a server side error --- diff --git a/public/js/syj.js b/public/js/syj.js index bfd0a64..9e5b602 100644 --- a/public/js/syj.js +++ b/public/js/syj.js @@ -517,8 +517,14 @@ var SYJView = { }, saveSuccess: function(transport) { - this.unsavedRoute = null; + // server sends and empty response on success. If we get a response, that + // probably means an error or warning has been printed by server. + if (!transport.responseJSON && transport.responseText.length) { + this.saveFailure(null, 500); + return; + } + this.unsavedRoute = null; if (transport.responseJSON && (typeof transport.responseJSON.redirect === "string")) { location = transport.responseJSON.redirect; return; @@ -529,12 +535,12 @@ var SYJView = { document.title = $('geom_title').value; }, - saveFailure: function(transport) { - var httpCode = 0, message = ""; - - if (transport) { - httpCode = transport.getStatus(); + saveFailure: function(transport, httpCode) { + var message = ""; + if (typeof httpCode === "undefined") { + httpCode = transport? transport.getStatus(): 0; } + switch (httpCode) { case 0: message = SyjStrings.notReachedError;