Sometimes, thrown exception messages are obfuscated by the exception handler
When my code throws an exception, I often get the output below instead of the actual exception:
/usr/local/bin/expresso:648 stack = err.stack.replace(err.name, ''), ^ TypeError: Cannot call method 'replace' of undefined at error (/usr/local/bin/expresso:648:27) at next (/usr/local/bin/expresso:684:21) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13) at next (/usr/local/bin/expresso:687:13)
Here is a sample test to reproduce this - http://gist.github.com/503625
hmm with 0.6.0 I get:
λ js: expresso bug.js
bug.js throw exception: SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at TheErrorator (/Users/tj/Testing/js/bug.js:2:10)
at /Users/tj/Testing/js/bug.js:7:2
at next (/Users/tj/.nvm/current/bin/expresso:674:21)
at runSuite (/Users/tj/.nvm/current/bin/expresso:689:6)
at check (/Users/tj/.nvm/current/bin/expresso:586:16)
at runFile (/Users/tj/.nvm/current/bin/expresso:590:10)
at Array.forEach (native)
at runFiles (/Users/tj/.nvm/current/bin/expresso:569:11)
at run (/Users/tj/.nvm/current/bin/expresso:545:5)
Failures: 1
Really strange. I updated expresso before testing this - some proof in case you don't believe me =) - http://gist.github.com/505292
I'm on OS X 10.6. I'll take a look at this when I get a chance (might not be for a couple of weeks though), so no need to worry about it if it's just something odd with my setup.
weiiird man! I am on osx 1.6.3
This is because errors thrown by clients may not be instances of Error. Here's a quick fix: http://github.com/Raevel/expresso/commit/987f9326d018e327977aee7c7495adb09fd97ae6
they should be :s node is throwing non Errors?
Yeah they should be, but i don't think expresso should break because of it :-)
Also, you might want to use try/catch for things other than errors/exceptions.
No, this was Joose3 throwing a string instead of an Error.
:( lol booo haha