You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for amazing project! Very exciting to be able to use v8 so easily.
I'm providing my JS script an API implemented with a Go FunctionCallback. If an error occurs, how do I signal that to the caller? Throwing a JS error seems like the correct route, but I don't see any way to do that.
For example
global, _:=v8go.NewObjectTemplate(iso)
fn, _:=v8go.NewFunctionTemplate(iso, func(info*v8go.FunctionCallbackInfo) *v8go.Value {
// HOW TO RAISE A JS ERROR?returnnil
})
global.Set("myfn", fn)
Thank you
The text was updated successfully, but these errors were encountered:
Hey @robfig
Thanks for your interest in the project.
This is unfortunately not possible 😢
I had tried to get this to work as part of the Basic Promise PR, but I had issues creating Error values... just kept crashing.
I left it out for now but plan to work on it to have it working again. Ref: #76 (comment)
If you use the latest changes on master, then there is now a Function.NewInstance function that can be used to call a function as a constructor (e.g. like new Error(message)). I think the only thing left is to add an Isolate.ThrowException method.
A workaround would be to execute some JS code to throw the exception (or define a function to do that). This code is on the slow path, so that may be acceptable.
dylanahsmith
changed the title
Question - Raising an error from a FunctionCallback
Add Isolate.ThrowException(exception) support
Aug 19, 2021
Thanks for amazing project! Very exciting to be able to use v8 so easily.
I'm providing my JS script an API implemented with a Go FunctionCallback. If an error occurs, how do I signal that to the caller? Throwing a JS error seems like the correct route, but I don't see any way to do that.
For example
Thank you
The text was updated successfully, but these errors were encountered: