Hi, all!

This is not a bug report, but a potential minor gotcha for v8 users. i've
been making this mistake consistently for about 2.5 years and only realized
it last week...

>From InvocationCallback implementations it's common (for me) to do:

return v8::ThrowException(v8::String::New(...));

what i didn't realize (until last week) was that in JS this translates to:

try { ... } catch(e) { print(typeof e); }

== 'string'

Which is, in hindsight, 100% expected (but i had never really thought about
it before). i had never noticed it because all my code just prints out
exceptions as strings.

So... the "correct" way to throw an Error looks like:

ThrowException(Exception::Error(String::New(...)))

Happy Hacking!

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to