| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9a410a1 commit 593714e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -172,9 +172,18 @@ EventEmitter.prototype.emit = function emit(type, ...args) { | |||
| 172 | 172 | // up in Node's output if this results in an unhandled exception. | |
| 173 | 173 | throw er; // Unhandled 'error' event | |
| 174 | 174 | } | |
| 175 | + | ||
| 176 | + let stringifiedEr; | ||
| 177 | + const { inspect } = require('internal/util/inspect'); | ||
| 178 | + try { | ||
| 179 | + stringifiedEr = inspect(er); | ||
| 180 | + } catch { | ||
| 181 | + stringifiedEr = er; | ||
| 182 | + } | ||
| 183 | + | ||
| 175 | 184 | // At least give some kind of context to the user | |
| 176 | 185 | const errors = lazyErrors(); | |
| 177 | - const err = new errors.ERR_UNHANDLED_ERROR(er); | ||
| 186 | + const err = new errors.ERR_UNHANDLED_ERROR(stringifiedEr); | ||
| 178 | 187 | err.context = er; | |
| 179 | 188 | throw err; // Unhandled 'error' event | |
| 180 | 189 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const EventEmitter = require('events'); | |
| 4 | + const util = require('util'); | ||
| 4 | 5 | ||
| 5 | 6 | const EE = new EventEmitter(); | |
| 6 | 7 | ||
@@ -9,12 +10,24 @@ common.expectsError( | |||
| 9 | 10 | { | |
| 10 | 11 | code: 'ERR_UNHANDLED_ERROR', | |
| 11 | 12 | type: Error, | |
| 12 | - message: 'Unhandled error. (Accepts a string)' | ||
| 13 | + message: "Unhandled error. ('Accepts a string')" | ||
| 13 | 14 | } | |
| 14 | 15 | ); | |
| 15 | 16 | ||
| 16 | 17 | common.expectsError( | |
| 17 | 18 | () => EE.emit('error', { message: 'Error!' }), | |
| 19 | + { | ||
| 20 | + code: 'ERR_UNHANDLED_ERROR', | ||
| 21 | + type: Error, | ||
| 22 | + message: "Unhandled error. ({ message: 'Error!' })" | ||
| 23 | + } | ||
| 24 | + ); | ||
| 25 | + | ||
| 26 | + common.expectsError( | ||
| 27 | + () => EE.emit('error', { | ||
| 28 | + message: 'Error!', | ||
| 29 | + [util.inspect.custom]() { throw new Error(); } | ||
| 30 | + }), | ||
| 18 | 31 | { | |
| 19 | 32 | code: 'ERR_UNHANDLED_ERROR', | |
| 20 | 33 | type: Error, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments