From a76c3ca7ddb6d69e1c3f84800bcc98bf5d24cefb Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 23 Feb 2016 17:01:44 +0100 Subject: Rework the callback error handler to use the browser console for outputting debug info if the logger is not available Also, clean some leftover dead code --- .../source/prado/activecontrols/ajax3.js | 270 +++++---------------- 1 file changed, 54 insertions(+), 216 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 4b6a4d2a..c50535ca 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -324,9 +324,40 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, return null; }, + getLogger: function() + { + if(typeof Logger != "undefined") + return Logger; + + // use the browser console if no Logger is available + if(typeof console != "undefined") + return console; + + return null; + }, + errorHandler: function(request, textStatus, errorThrown) { -//null) are "timeout", "error", "abort", and "parsererror" + this.data = request.responseText; + + if(log = this.getLogger()) + { + log.warn("Ajax callback error:", request.status, "(" + request.statusText + ")"); + if(request.status==500) + { + /** + * Server returns 500 exception. Just log it. + */ + var errorData = this.extractContent(Prado.CallbackRequestManager.ERROR_HEADER); + if (typeof(errorData) == "string" && errorData.length > 0) + { + errorData = jQuery.parseJSON(errorData); + if(typeof(errorData) == "object") + log.info(Prado.CallbackRequestManager.formatException(errorData)); + } + } + } + if (this.options.onFailure) this.options.onFailure(this,textStatus); }, @@ -343,22 +374,16 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, */ exceptionHandler: function(e) { - if (this.options.onException) - this.options.onException(this,e); - /* - var msg = ""; - jQuery.each(e, function(item) + if(log = this.getLogger()) { - msg += item.key+": "+item.value+"\n"; - }) - */ - if(typeof(Logger) != "undefined") - { - Logger.error('Uncaught Callback Client Exception:', e.message); - Logger.error('Stack:', e.message); + log.warn("Uncaught Callback Client Exception:", e.message); + log.info('Stack:', e.stack); } else { debugger; } + + if (this.options.onException) + this.options.onException(this,e); }, /** @@ -368,6 +393,22 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { this.data = data; + if(log = this.getLogger()) + { + log.info('HTTP '+request.status+" with response : \n"); + + var tagStart = '