From bd3de07b5ee90369741ef197230b4744f33eeda1 Mon Sep 17 00:00:00 2001 From: arno Date: Fri, 18 Mar 2011 13:35:42 +0100 Subject: [PATCH] warns user when there is a server side error --- public/js/syj.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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; -- 2.39.2