Hello v8 users
If you ever throw an exception through v8's C++ api that has already
been caught by a v8::TryCatch you may want to change your code to
using the TryCatch::ReThrow method that was added in bleeding_edge
revision 3201. The problem with not using this function is the
following. If you want to know if an exception is thrown but still
let it propagate out you might do something like this:
v8::TryCatch try_catch;
/* ... do something that might throw ... */
if (try_catch.HasCaught()) {
return v8::ThrowException(try_catch.Exception());
}
/* ... no exception, continue ... */
We had code like this in several places in chromium. The problem is
that the TryCatch is still in effect when throwing the exception again
so it will actually be caught immediately and won't be propagated any
further. That can have some unexpected consequences. The correct way
to handle this situation is to use the new TryCatch::ReThrow method:
v8::TryCatch try_catch;
/* ... */
if (try_catch.HasCaught()) {
return try_catch.ReThrow();
}
This will cause the exception to be thrown "around" the try_catch so
it will be propagated correctly into the next exception handler in
line -- what you expect, basically. If this situation looks familiar
to you, you may want to check your code to see if it needs to be
rewritten to use this.
-- Christian
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---