0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-event-emitter-errors.js
Chris Burkhart 2141d37452 events: update and clarify error message
Update error message that's thrown when no error listeners are attached
to an emitter.

PR-URL: https://github.com/nodejs/node/pull/10387
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-03-24 16:07:35 -07:00

15 lines
396 B
JavaScript

'use strict';
require('../common');
const EventEmitter = require('events');
const assert = require('assert');
const EE = new EventEmitter();
assert.throws(() => {
EE.emit('error', 'Accepts a string');
}, /^Error: Unhandled "error" event\. \(Accepts a string\)$/);
assert.throws(() => {
EE.emit('error', {message: 'Error!'});
}, /^Error: Unhandled "error" event\. \(\[object Object\]\)$/);