Opened 12 years ago

Closed 10 years ago

#11945 closed defect (wontfix)

Telling deferred.errback from deferred.cancel

Reported by: Shashank Owned by: Mark Wubben
Priority: high Milestone: tbd
Component: Core Version: 1.5
Keywords: deferred, cancel Cc:
Blocked By: Blocking:


In my understanding, Deferred.cancel always fires errback (unless the deferred is already finished). How do I differentiate, in the error handler, whether it has been called due to an error or due to a cancellation?

In v 1.4 checking the error.message text was one solution (admittedly not the best solution, but it worked). In 1.5 there is no such error message that one could use.

Setting a flag on the error being returned or adding a flag to the deferred object itself can solve the problem, e.g. this change against the trunk Index: _base/Deferred.js =================================================================== --- _base/Deferred.js (revision 23174) +++ _base/Deferred.js (working copy) @@ -281,6 +281,7 @@

error = new Error(error);

} error.log = false;

+ error.isDeferredCancelled = true;




Change History (3)

comment:1 Changed 12 years ago by bill

Owner: changed from anonymous to Kris Zyp

comment:2 Changed 10 years ago by bill

Owner: changed from Kris Zyp to Mark Wubben
Status: newassigned

Not sure if this ticket is relevant anymore but assigning to Mark since it's about Deferreds.

comment:3 Changed 10 years ago by Mark Wubben

Resolution: wontfix
Status: assignedclosed

With 1.8, cancel() by default rejects with an instance of dojo/errors/CancelError, so that's one way of knowing. This could be changed by the deferred though. Typically you'd only handle expected errors in the errbacks and let other errors bubble through the promise chain.

Closing this because there is no actual bug.

Note: See TracTickets for help on using tickets.