expresso icon indicating copy to clipboard operation
expresso copied to clipboard

Sometimes, thrown exception messages are obfuscated by the exception handler

Open saikat opened this issue 15 years ago • 7 comments

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

saikat avatar Aug 01 '10 18:08 saikat

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

tj avatar Aug 02 '10 14:08 tj

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.

saikat avatar Aug 02 '10 20:08 saikat

weiiird man! I am on osx 1.6.3

tj avatar Aug 03 '10 16:08 tj

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

bergmark avatar Oct 19 '10 08:10 bergmark

they should be :s node is throwing non Errors?

tj avatar Oct 19 '10 15:10 tj

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.

bergmark avatar Oct 19 '10 18:10 bergmark

:( lol booo haha

tj avatar Oct 20 '10 00:10 tj