From 51e2e19014aae64b02b81626b4ffbcf0f3a8317d Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Mon, 4 Aug 2014 18:35:32 +0200 Subject: [PATCH] Improved Async logging in case of deferred being cancelled --- frontend/delta/js/Clipperz/Async.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/delta/js/Clipperz/Async.js b/frontend/delta/js/Clipperz/Async.js index e440e24..01b5a84 100644 --- a/frontend/delta/js/Clipperz/Async.js +++ b/frontend/delta/js/Clipperz/Async.js @@ -61,13 +61,18 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { } if (this.chained == false) { - var message; + var deferredName = this._name; - message = "ERROR [" + this._name + "]"; this.addErrback(function(aResult) { + var message; + if (! (aResult instanceof MochiKit.Async.CancelledError)) { - Clipperz.log(message, aResult); + message = "ERROR [" + deferredName + "]"; + } else { + message = "CANCELLED - " + deferredName; } + Clipperz.log(message, aResult); + return aResult; }); @@ -101,7 +106,7 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); this.addCallbacks( function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + function(aResult) {if (! (aResult instanceof MochiKit.Async.CancelledError)) { Clipperz.log("FAIL " + message + "-->"/*, aResult*/);}; return aResult;} ); } @@ -111,7 +116,7 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); this.addCallbacks( function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} + function(aResult) {if (! (aResult instanceof MochiKit.Async.CancelledError)) { Clipperz.log("FAIL " + message + "<--", aResult);}; return aResult;} ); } },