Skip to content

Commit

Permalink
util: fix exception stringification in .format()
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Sep 3, 2011
1 parent 3efebbe commit 7292023
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ function inspect(obj, showHidden, depth, colors) {
case 'boolean':
return stylize('' + value, 'boolean');
}

// For some reason typeof null is "object", so special case here.
if (value === null) {
return stylize('null', 'null');
}

// Look up the keys of the object.
var visible_keys = Object.keys(value);
var keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
var keys = showHidden || isException(value) ?
Object.getOwnPropertyNames(value) : visible_keys;

// Functions without properties can be shortcutted.
if (typeof value === 'function' && keys.length === 0) {
Expand Down Expand Up @@ -337,6 +339,12 @@ function isDate(d) {
}


function isException(e) {
return e instanceof Error ||
(typeof e === 'object' && Object.prototype.toString.call(e) === '[object Error]');
}


var pWarning;

exports.p = function() {
Expand Down

0 comments on commit 7292023

Please sign in to comment.