Skip to content

Commit 2acafe7

Browse files
committed
fix util.inspect(new Error(..)) for IE
IE is stupid and adds enumerable fields
1 parent 7740147 commit 2acafe7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

util.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ function formatValue(ctx, value, recurseTimes) {
239239
keys = Object.getOwnPropertyNames(value);
240240
}
241241

242+
// IE doesn't make error fields non-enumerable
243+
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
244+
if (isError(value)
245+
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
246+
return formatError(value);
247+
}
248+
242249
// Some type of object without properties can be shortcutted.
243250
if (keys.length === 0) {
244251
if (isFunction(value)) {

0 commit comments

Comments
 (0)