summaryrefslogtreecommitdiff
path: root/test/message
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-08-03 23:29:42 +0200
committerRich Trott <rtrott@gmail.com>2019-08-06 19:28:12 -0700
commit4c9fb0b706c6df44393e2b46985320c089aa1784 (patch)
treed02727400575d77be9ed28324e7d67d5309d89a1 /test/message
parent320402c1a18d877fa93c440af17b852612ff7f44 (diff)
downloadandroid-node-v8-4c9fb0b706c6df44393e2b46985320c089aa1784.tar.gz
android-node-v8-4c9fb0b706c6df44393e2b46985320c089aa1784.tar.bz2
android-node-v8-4c9fb0b706c6df44393e2b46985320c089aa1784.zip
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: https://github.com/nodejs/node/pull/28952 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/message')
-rw-r--r--test/message/events_unhandled_error_subclass.js5
-rw-r--r--test/message/events_unhandled_error_subclass.out17
2 files changed, 22 insertions, 0 deletions
diff --git a/test/message/events_unhandled_error_subclass.js b/test/message/events_unhandled_error_subclass.js
new file mode 100644
index 0000000000..8303cb2237
--- /dev/null
+++ b/test/message/events_unhandled_error_subclass.js
@@ -0,0 +1,5 @@
+'use strict';
+require('../common');
+const EventEmitter = require('events');
+class Foo extends EventEmitter {}
+new Foo().emit('error', new Error());
diff --git a/test/message/events_unhandled_error_subclass.out b/test/message/events_unhandled_error_subclass.out
new file mode 100644
index 0000000000..970533299a
--- /dev/null
+++ b/test/message/events_unhandled_error_subclass.out
@@ -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:*:*