Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion ayepromise.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@
}(this, function () {
'use strict';

var ayepromise = {};
var ayepromise =
{
suppressedErros: [],
debugMode: false
};

var logError = function(e)
{
if(ayepromise.debugMode)
{
ayepromise.suppressedErros.push(e);

if(console)
{
console.error('The following error was thrown, but suppressed by ayepromise, you can debug it with ayepromise.suppressedErros.', e);
}
}
};

/* Wrap an arbitrary number of functions and allow only one of them to be
executed and only once */
Expand Down Expand Up @@ -47,6 +64,7 @@
try {
returnValue = func(value);
} catch (e) {
logError(e);
defer.reject(e);
return;
}
Expand Down Expand Up @@ -139,6 +157,7 @@
onceWrapper(doReject)
);
} catch (e) {
logError(e);
onceWrapper(doReject)(e);
}
};
Expand All @@ -149,6 +168,7 @@
try {
thenable = getThenableIfExists(value);
} catch (e) {
logError(e);
doReject(e);
return;
}
Expand Down