Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 833877: Add a way to report exceptions in promises. r=Mossop
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaisucan authored and Mossop committed Feb 28, 2013
1 parent 924d09e commit 1b26c75
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/sdk/core/promise.js
Expand Up @@ -9,6 +9,13 @@
factory.call(this, require, exports, module);
} else if (~String(this).indexOf('BackstagePass')) { // JSM
this[factory.name] = {};
try {
this.console = this['Components'].utils
.import('resource://gre/modules/devtools/Console.jsm', {}).console;
}
catch (ex) {
// Avoid failures on different toolkit configurations.
}
factory(function require(uri) {
var imports = {};
this['Components'].utils.import(uri, imports);
Expand Down Expand Up @@ -53,7 +60,12 @@ function attempt(f) {
**/
return function effort(options) {
try { return f(options) }
catch(error) { return rejection(error) }
catch(error) {
if (exports._reportErrors && typeof(console) === 'object') {
console.error(error)
}
return rejection(error)
}
}
}

Expand Down

0 comments on commit 1b26c75

Please sign in to comment.