Skip to content

Commit

Permalink
Improve root-level thrown error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 19, 2017
1 parent 9cba659 commit 7b96e86
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/base.js
Expand Up @@ -82,15 +82,25 @@ Base.prototype.threw = function (er, extra, proxy) {
if (this.name && !proxy)
er.test = this.name

var message = er.message

if (!extra)
extra = extraFromError(er, extra, this.options)

if (this.results) {
if (this.results || this.ended) {
this.results.ok = false
if (this.parent)
this.parent.threw(er, extra, true)
else
console.error(er, er.stack)
else if (!er.stack)
console.error(er)
else {
er.message = message
delete extra.stack
delete extra.at
console.error('%s: %s', er.name || 'Error', message)
console.error(er.stack.split(/\n/).slice(1).join('\n'))
console.error(extra)
}
} else
this.parser.ok = false

Expand Down

0 comments on commit 7b96e86

Please sign in to comment.