mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
d5d7a416c7
As much as I would like to do this everywhere and then modify the lint rule to enforce it, the churn would be too big. However if we're going to have relatively frequent nits for this sort of thing (as we do), I'd prefer we migrate a few files at a time to never actually getting around to doing it. Ref: https://github.com/nodejs/node/pull/45448#pullrequestreview-1179370442 PR-URL: https://github.com/nodejs/node/pull/45466 Reviewed-By: James M Snell <jasnell@gmail.com>
38 lines
774 B
JavaScript
38 lines
774 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const EventEmitter = require('events');
|
|
const util = require('util');
|
|
|
|
const EE = new EventEmitter();
|
|
|
|
assert.throws(
|
|
() => EE.emit('error', 'Accepts a string'),
|
|
{
|
|
code: 'ERR_UNHANDLED_ERROR',
|
|
name: 'Error',
|
|
message: "Unhandled error. ('Accepts a string')",
|
|
}
|
|
);
|
|
|
|
assert.throws(
|
|
() => EE.emit('error', { message: 'Error!' }),
|
|
{
|
|
code: 'ERR_UNHANDLED_ERROR',
|
|
name: 'Error',
|
|
message: "Unhandled error. ({ message: 'Error!' })",
|
|
}
|
|
);
|
|
|
|
assert.throws(
|
|
() => EE.emit('error', {
|
|
message: 'Error!',
|
|
[util.inspect.custom]() { throw new Error(); },
|
|
}),
|
|
{
|
|
code: 'ERR_UNHANDLED_ERROR',
|
|
name: 'Error',
|
|
message: 'Unhandled error. ([object Object])',
|
|
}
|
|
);
|