diff options
author | isaacs <i@izs.me> | 2010-08-24 08:04:56 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-08-24 09:52:09 +0400 |
commit | 7be1fe7571dd45fe28f315edd4b8e438a6b0ad86 (patch) | |
tree | ae0c54a86d901791f527982ba09fbc52890efc47 | |
parent | bdd172fc75b0ae30d5cc41bd6a5cbbfdbcc58648 (diff) |
Handle errors smarter
-rw-r--r-- | lib/utils/log.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/utils/log.js b/lib/utils/log.js index dc66a014c..2f2650d57 100644 --- a/lib/utils/log.js +++ b/lib/utils/log.js @@ -89,10 +89,13 @@ function log (msg, pref, level, cb) { if (level == null) level = LEVEL.info if (isNaN(level)) level = LEVEL[level] else level = +level - if (msg instanceof Error) msg = msg.stack || msg.toString() - if (typeof msg !== "string") { + if (typeof msg !== "string" && !(msg instanceof Error)) { msg = sys.inspect(msg, 0, 4) } + if (msg instanceof Error) { + msg = msg.stack || msg.toString() + level = LEVEL.error + } if (!ini.resolved) { return logBuffer.push([msg, pref, level]) } |