-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events: give subclass name in unhandled 'error' message
For unhandled `'error'` events, include the constructor name for subclasses of EventEmitter, if possible. This makes tracing errors easier when both creation of the `Error` object and emitting it happen in code that does not refer back to the event emitter. PR-URL: #28952 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
require('../common'); | ||
const EventEmitter = require('events'); | ||
class Foo extends EventEmitter {} | ||
new Foo().emit('error', new 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,17 @@ | ||
events.js:* | ||
throw er; // Unhandled 'error' event | ||
^ | ||
|
||
Error | ||
at Object.<anonymous> (*events_unhandled_error_subclass.js:*:*) | ||
at Module._compile (internal/modules/cjs/loader.js:*:*) | ||
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) | ||
at Module.load (internal/modules/cjs/loader.js:*:*) | ||
at Function.Module._load (internal/modules/cjs/loader.js:*:*) | ||
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) | ||
at internal/main/run_main_module.js:*:* | ||
Emitted 'error' event on Foo instance at: | ||
at Object.<anonymous> (*events_unhandled_error_subclass.js:*:*) | ||
at Module._compile (internal/modules/cjs/loader.js:*:*) | ||
[... lines matching original stack trace ...] | ||
at internal/main/run_main_module.js:*:* |