Permalink
Browse files

Bugfix: multi-line error messages where handled incorrectly

  • Loading branch information...
1 parent 9416d7b commit 528bd67d5c352fe6861954631d957ea3d280e5ff @DennisKehrig committed Sep 29, 2012
Showing with 34 additions and 10 deletions.
  1. +17 −5 lib/exception-handler.js
  2. +1 −1 package.json
  3. +16 −4 src/exception-handler.coffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "ansinception",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Colorful exception handler for Node.js with CoffeeScript support and improved nodemon/supervisor compatibility",
"author": {
"name": "Dennis Kehrig"
@@ -59,9 +59,16 @@ exports.handler = (exception) ->
console.log "\n#{baseColor} ,-- $ #{brightCyan}#{process.argv.join ' '}#{reset}"
# Split the stack into lines
- stack = exception.stack.split "\n"
- # Remove the first line and store it as the message
- message = stack.shift()
+ stack = exception.stack.split "\n"
+
+ # Collect the lines with the error message
+ messageLines = []
+ for entry in stack
+ break if entry.match(format1) or entry.match(format2)
+ messageLines.push entry
+
+ # Remove the message lines from the stack
+ stack.splice 0, messageLines.length
# Print the stack chronologically
for entry in stack.reverse()
@@ -77,8 +84,13 @@ exports.handler = (exception) ->
# Just dump the line if we don't recognize it
else
console.log "#{baseColor} `-> #{entry}#{reset}"
+
+ errorStyle = "#{darkRed}|#{brightWhite} "
- console.log "#{baseColor} `-> #{brightRed}#{message}#{reset}\n"
+ console.log "#{baseColor} v#{reset}"
+ console.log "#{darkRed},---------------------------------------------------------------------------#{reset}"
+ console.log "#{errorStyle}" + messageLines.join "\n#{errorStyle}"
+ console.log "#{darkRed}`---------------------------------------------------------------------------#{reset}"
# Delay exiting when an exception occurs so console.log calls that occured
# just before the error are also printed by nodemon, supervisor, etc.

0 comments on commit 528bd67

Please sign in to comment.