Throwable that can't be caught by JavaScript.

129 views
Skip to first unread message

Jane Chen

unread,
Jun 26, 2014, 12:53:27 AM6/26/14
to v8-u...@googlegroups.com
I need a way to throw an exception from a function callback.  For this type of exception, I don't want the script to catch it, but instead, I'd like v8 to throw it out to my system so that I can catch it and re-run the script.  Does v8 provide such an API?  If not, is there some kind of work-around I could use? 

I'm on 3.24 but could upgrade to trunk if needed.

Ingwie Phoenix

unread,
Jun 26, 2014, 12:56:16 AM6/26/14
to v8-u...@googlegroups.com
Exceptions are there to be caught O.o
If you want to „catch“ a failure via your syste, consider terminating the actual process with a error message or error code, that oyur system understands.

Am 26.06.2014 um 06:53 schrieb Jane Chen <jxch...@gmail.com>:

I need a way to throw an exception from a function callback.  For this type of exception, I don't want the script to catch it, but instead, I'd like v8 to throw it out to my system so that I can catch it and re-run the script.  Does v8 provide such an API?  If not, is there some kind of work-around I could use? 

I'm on 3.24 but could upgrade to trunk if needed.

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Noordhuis

unread,
Jun 26, 2014, 3:21:03 AM6/26/14
to v8-u...@googlegroups.com
V8::TerminateExecution() in combination with
V8::CancelTerminateExecution()? They're available in 3.24. You can
discriminate between a regular exception and a termination exception
with TryCatch::HasTerminated().

Caveat emptor, a termination exception is not immediately active. See
this thread[1] for details and a workaround.

[1] https://groups.google.com/forum/#!topic/v8-users/SpzuB-lTgcI

Jane Chen

unread,
Jun 26, 2014, 12:41:34 PM6/26/14
to v8-u...@googlegroups.com
Thanks Ben.  I saw it and was thinking that could be my last resort.

Does terminateExecution tear down the isolate or just terminate execution of one script?  Do my cached persistent handles survive a terminateExecution?

Ben Noordhuis

unread,
Jun 27, 2014, 12:06:21 AM6/27/14
to v8-u...@googlegroups.com
On Thu, Jun 26, 2014 at 6:41 PM, Jane Chen <jxch...@gmail.com> wrote:
> Thanks Ben. I saw it and was thinking that could be my last resort.
>
> Does terminateExecution tear down the isolate or just terminate execution of
> one script? Do my cached persistent handles survive a terminateExecution?

Just the currently executing script. You can reenter the VM (i.e. the
isolate) again after cancelling termination. Any strong persistent
handles you have will stay around. I believe weak ones won't get
garbage collected either while the termination exception is in effect
but I'm not 100% sure about that.
Reply all
Reply to author
Forward
0 new messages