Skip to content

Commit f631f0c

Browse files
committed
Fixed by review
1 parent 6be2bba commit f631f0c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/promise.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
_isPromisesAPlusCompliant: true,
4747
_debugError: false,
4848

49+
setPromisesAPlusCompliant: function(isCompliant) {
50+
AV.Promise._isPromisesAPlusCompliant = isCompliant;
51+
},
52+
53+
setDebugError: function(enable) {
54+
AV.Promise._debugError = enable;
55+
},
56+
4957
/**
5058
* Returns true iff the given object fulfils the Promise interface.
5159
* @return {Boolean}
@@ -363,7 +371,7 @@
363371
result = [resolvedCallback.apply(this, result)];
364372
} catch (e) {
365373
if(AV.Promise._debugError && e) {
366-
console.error('Error occurred in promise resolve callback', e);
374+
console.error('Error occurred in promise resolve callback.', e.stack || e);
367375
}
368376
result = [AV.Promise.error(e)];
369377
}
@@ -390,7 +398,7 @@
390398
result = [rejectedCallback(error)];
391399
} catch (e) {
392400
if(AV.Promise._debugError && e) {
393-
console.error('Error occurred in promise reject callback', e);
401+
console.error('Error occurred in promise reject callback.', e.stack || e);
394402
}
395403
result = [AV.Promise.error(e)];
396404
}

test/promise.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ describe('promise', function() {
2626

2727
describe('AV.Promise._debugError', function() {
2828
it('should log error', function(done) {
29-
AV.Promise._debugError = true;
29+
AV.Promise.setDebugError(true);
3030
var p = new AV.Promise();
3131
p.then(function() {
3232
noThisMethod();
3333
});
3434
p.resolve(100);
3535
p.finally(function(){
36-
AV.Promise._debugError = false;
36+
AV.Promise.setDebugError(false);
3737
done();
3838
});
3939
});

0 commit comments

Comments
 (0)