Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

util: fix exception stringification in .format()

Fixes #1634.
  • Loading branch information...
commit 72920231067107780abc7bf03ff6df0bb027821e 1 parent 3efebbe
@bnoordhuis bnoordhuis authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/util.js
View
10 lib/util.js
@@ -164,6 +164,7 @@ 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');
@@ -171,7 +172,8 @@ function inspect(obj, showHidden, depth, colors) {
// 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) {
@@ -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() {
Please sign in to comment.
Something went wrong with that request. Please try again.