1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const EventEmitter = require('events'); 5const util = require('util'); 6 7const EE = new EventEmitter(); 8 9assert.throws( 10 () => EE.emit('error', 'Accepts a string'), 11 { 12 code: 'ERR_UNHANDLED_ERROR', 13 name: 'Error', 14 message: "Unhandled error. ('Accepts a string')" 15 } 16); 17 18assert.throws( 19 () => EE.emit('error', { message: 'Error!' }), 20 { 21 code: 'ERR_UNHANDLED_ERROR', 22 name: 'Error', 23 message: "Unhandled error. ({ message: 'Error!' })" 24 } 25); 26 27assert.throws( 28 () => EE.emit('error', { 29 message: 'Error!', 30 [util.inspect.custom]() { throw new Error(); } 31 }), 32 { 33 code: 'ERR_UNHANDLED_ERROR', 34 name: 'Error', 35 message: 'Unhandled error. ([object Object])' 36 } 37); 38