[Pkg-javascript-commits] [dojo] 02/20: Allow downstream error handling
David Prévot
taffit at moszumanska.debian.org
Mon Oct 20 17:39:37 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository dojo.
commit e16adb441dea583492415dc79f240a14a3485ea0
Author: Kris Zyp <kriszyp at gmail.com>
Date: Thu Jun 26 22:27:02 2014 -0600
Allow downstream error handling
Allow errors to be handled after rejection passes through unhandled
rejections, so rejections don't show as unhandled if downstream promises
handle them, refs #18131.
---
promise/instrumentation.js | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/promise/instrumentation.js b/promise/instrumentation.js
index 49bf127..a5be441 100644
--- a/promise/instrumentation.js
+++ b/promise/instrumentation.js
@@ -30,17 +30,22 @@ define([
var activeTimeout = false;
var unhandledWait = 1000;
function trackUnhandledRejections(error, handled, rejection, deferred){
- if(handled){
- arrayUtil.some(errors, function(obj, ix){
- if(obj.error === error){
- errors.splice(ix, 1);
- return true;
+ // try to find the existing tracking object
+ if(!arrayUtil.some(errors, function(obj){
+ if(obj.error === error){
+ // found the tracking object for this error
+ if(handled){
+ // if handled, update the state
+ obj.handled = true;
}
- });
- }else if(!arrayUtil.some(errors, function(obj){ return obj.error === error; })){
+ return true;
+ }
+ })){
+ // no tracking object has been setup, create one
errors.push({
error: error,
rejection: rejection,
+ handled: handled,
deferred: deferred,
timestamp: new Date().getTime()
});
@@ -55,8 +60,12 @@ define([
var now = new Date().getTime();
var reportBefore = now - unhandledWait;
errors = arrayUtil.filter(errors, function(obj){
+ // only report the error if we have waited long enough and
+ // it hasn't been handled
if(obj.timestamp < reportBefore){
- logError(obj.error, obj.rejection, obj.deferred);
+ if(!obj.handled){
+ logError(obj.error, obj.rejection, obj.deferred);
+ }
return false;
}
return true;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list