2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2019-12-25 18:02:16 +01:00
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
2016-12-30 18:38:06 -05:00
|
|
|
const EventEmitter = require('events');
|
2019-01-21 20:45:55 +01:00
|
|
|
const util = require('util');
|
2015-05-07 16:09:31 -05:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const EE = new EventEmitter();
|
2015-05-07 16:09:31 -05:00
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2017-09-25 21:43:32 -07:00
|
|
|
() => EE.emit('error', 'Accepts a string'),
|
|
|
|
{
|
|
|
|
code: 'ERR_UNHANDLED_ERROR',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'Error',
|
2019-01-21 20:45:55 +01:00
|
|
|
message: "Unhandled error. ('Accepts a string')"
|
2017-09-25 21:43:32 -07:00
|
|
|
}
|
|
|
|
);
|
2016-12-21 09:32:21 -08:00
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2017-09-25 21:43:32 -07:00
|
|
|
() => EE.emit('error', { message: 'Error!' }),
|
2019-01-21 20:45:55 +01:00
|
|
|
{
|
|
|
|
code: 'ERR_UNHANDLED_ERROR',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'Error',
|
2019-01-21 20:45:55 +01:00
|
|
|
message: "Unhandled error. ({ message: 'Error!' })"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2019-01-21 20:45:55 +01:00
|
|
|
() => EE.emit('error', {
|
|
|
|
message: 'Error!',
|
|
|
|
[util.inspect.custom]() { throw new Error(); }
|
|
|
|
}),
|
2017-09-25 21:43:32 -07:00
|
|
|
{
|
|
|
|
code: 'ERR_UNHANDLED_ERROR',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'Error',
|
2017-09-25 21:43:32 -07:00
|
|
|
message: 'Unhandled error. ([object Object])'
|
|
|
|
}
|
|
|
|
);
|