forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e9d1c8
commit 980fb8f
Showing
9 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var common = require('../common'); | ||
|
||
Promise.reject(new Error('error')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
node.js:* | ||
throw value; | ||
^ | ||
Error: error | ||
at Object.<anonymous> (*test*message*unhandled_rejection.js:*) | ||
at Module._compile (module.js:*) | ||
at Object.Module._extensions..js (module.js:*) | ||
at Module.load (module.js:*) | ||
at Function.Module._load (module.js:*) | ||
at Function.Module.runMain (module.js:*) | ||
at startup (node.js:*) | ||
at node.js:* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
/** | ||
* Unhandled rejections are thrown by default | ||
* and should be available in `uncaughtException`. | ||
*/ | ||
|
||
var caught = null; | ||
|
||
process.once('uncaughtException', function(error) { | ||
caught = error; | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert(caught); | ||
}); | ||
|
||
var error = new Error('error'); | ||
Promise.reject(error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
/** | ||
* In `unhandledPromiseRejection` handler `rejection` | ||
* object is available. If `rejection.handle()` is | ||
* not called `rejection.value` is thrown. | ||
*/ | ||
|
||
var caught = false; | ||
var unhandledRejection = null; | ||
|
||
process.once('uncaughtException', function() { | ||
caught = true; | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert(caught); | ||
assert.equal(unhandledRejection.promise, promise); | ||
assert.equal(unhandledRejection.value, error); | ||
assert.equal(unhandledRejection.isHandled(), false); | ||
}); | ||
|
||
process.on('unhandledPromiseRejection', function(promise, rejection) { | ||
unhandledRejection = rejection; | ||
}); | ||
|
||
var error = new Error('error'); | ||
var promise = Promise.reject(error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
/** | ||
* If `rejection.handle()` is called rejection is not | ||
* thrown. | ||
*/ | ||
|
||
var unhandledRejection = null; | ||
|
||
process.on('exit', function() { | ||
assert.equal(unhandledRejection.promise, promise); | ||
assert.equal(unhandledRejection.value, error); | ||
}); | ||
|
||
process.on('unhandledPromiseRejection', function(promise, rejection) { | ||
unhandledRejection = rejection; | ||
rejection.handle(); | ||
}); | ||
|
||
var error = new Error('error'); | ||
var promise = Promise.reject(error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
/** | ||
* `rejection.promise` should be last | ||
* promise in chain, not original rejected | ||
* promise. | ||
*/ | ||
|
||
var unhandledRejection = null; | ||
|
||
process.on('exit', function() { | ||
assert.equal(unhandledRejection.promise, promise2); | ||
assert.equal(unhandledRejection.value, error); | ||
}); | ||
|
||
process.on('unhandledPromiseRejection', function(promise, rejection) { | ||
unhandledRejection = rejection; | ||
rejection.handle(); | ||
}); | ||
|
||
var error = new Error('error'); | ||
var promise = new Promise(function(resolve, reject) { | ||
setImmediate(reject.bind(null, error)); | ||
}); | ||
|
||
var promise2 = promise.then(function() {}); |