Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack trace of errors propagated by expect.withError #194

Closed
wants to merge 1 commit into from

Conversation

papandreou
Copy link
Member

I don't understand exactly how this fixes the problem, but it changes the stack from:

UnexpectedError: 
expected 2 to equal 'wat'
    at callInNestedContext (/home/andreas/work/unexpected/lib/Unexpected.js:653:44)
    at Function.wrappedExpect.fail (/home/andreas/work/unexpected/lib/Unexpected.js:690:17)
    at /home/andreas/work/unexpected/lib/assertions.js:425:20
    at /home/andreas/work/unexpected/lib/Unexpected.js:698:28
    at tryCatcher (/home/andreas/work/unexpected/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/home/andreas/work/unexpected/node_modules/bluebird/js/main/promise.js:454:31)
    at Promise._settlePromiseAt (/home/andreas/work/unexpected/node_modules/bluebird/js/main/promise.js:530:18)
    at Promise._settlePromiseAtPostResolution (/home/andreas/work/unexpected/node_modules/bluebird/js/main/promise.js:224:10)
    at Async._drainQueue (/home/andreas/work/unexpected/node_modules/bluebird/js/main/async.js:182:12)
    at Async._drainQueues (/home/andreas/work/unexpected/node_modules/bluebird/js/main/async.js:187:10)
    at Async.drainQueues (/home/andreas/work/unexpected/node_modules/bluebird/js/main/async.js:15:14)
    at /home/andreas/work/unexpected/lib/workQueue.js:8:13
    at Array.forEach (native)
    at Object.workQueue.drain (/home/andreas/work/unexpected/lib/workQueue.js:7:20)
    at oathbreaker (/home/andreas/work/unexpected/lib/oathbreaker.js:43:15)
    at Function.wrappedExpect.withError (/home/andreas/work/unexpected/lib/Unexpected.js:696:24)

to

UnexpectedError: 
expected 2 to equal 'wat'
    at callInNestedContext (/home/andreas/work/unexpected/lib/Unexpected.js:653:44)
    at Function.wrappedExpect.fail (/home/andreas/work/unexpected/lib/Unexpected.js:690:17)
    at /home/andreas/work/unexpected/lib/assertions.js:425:20
    at Function.wrappedExpect.withError (/home/andreas/work/unexpected/lib/Unexpected.js:702:28)
    at Assertion.<anonymous> (/home/andreas/work/unexpected/lib/assertions.js:422:16)
    at executeExpect (/home/andreas/work/unexpected/lib/Unexpected.js:720:34)
    at Unexpected.expect (/home/andreas/work/unexpected/lib/Unexpected.js:798:22)
    at Object.<anonymous> (/home/andreas/work/unexpected/argh.js:3:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

when I run my test script, argh.js with this content from the root of my unexpected checkout:

var expect = require('./lib/');

expect(2, 'to equal', 'wat');

It's seems very likely that it's just masking a bug in oathbreaker or makePromise, though :/

@sunesimonsen
Copy link
Member

I think this masking a bug, see the following evaluation:

> require('./lib/makePromise')(function () { throw new Error('wat')}).caught(function (err) { throw err; }).isRejected()
false
> 
/home/ubuntu-sune/Projects/unexpected/lib/workQueue.js:29
                throw that.reason();
                           ^
Error: wat
    at repl:1:34
    at /home/ubuntu-sune/Projects/unexpected/lib/makePromise.js:59:38
    at tryCatcher (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._resolveFromResolver (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/promise.js:427:31)
    at new Promise (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/promise.js:53:37)
    at makePromise (/home/ubuntu-sune/Projects/unexpected/lib/makePromise.js:16:12)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)

@papandreou
Copy link
Member Author

I also played with it a bit more this morning, looking through makePromise.js, but I didn't get any closer to the root cause.

@sunesimonsen
Copy link
Member

I'll see if I can get some time to look at it today, otherwise we should just merge the pr.

@sunesimonsen
Copy link
Member

This actually works:

> require('./lib/oathbreaker')(require('./lib/makePromise')(function () { throw new Error('wat') }).caught(function (err) { throw err; }))
Error: wat
    at repl:1:80
    at /home/ubuntu-sune/Projects/unexpected/lib/makePromise.js:59:38
    at tryCatcher (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._resolveFromResolver (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/promise.js:427:31)
    at new Promise (/home/ubuntu-sune/Projects/unexpected/node_modules/bluebird/js/main/promise.js:53:37)
    at makePromise (/home/ubuntu-sune/Projects/unexpected/lib/makePromise.js:16:12)
    at repl:1:59
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)

But this doesn't:

> require('./lib/oathbreaker')(require('./lib/makePromise')(function (run) { run(function () {throw new Error('wat')}) }).caught(function (err) { throw err; }))
{ _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _progressHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined,
  _settledValue: undefined }

@papandreou
Copy link
Member Author

Superseeded by #197.

@papandreou papandreou closed this Jul 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants