Saturday, March 11, 2023
HomeGolangExactly how to capture exemption when calling a "syscall/js" feature? - Obtaining...

Exactly how to capture exemption when calling a “syscall/js” feature? – Obtaining Assistance

Hi friend,
I’m experiencing making use of the syscall/js bundle as well as I require aid to locate a means to capture exemption on a phone call to a js feature.

Right here an instance:

 worth:= js.Global(). Obtain(" home window"). Obtain(" localStorage").

If you disable the accessibility to the localstorage right into your internet browser after that it increase the complying with exemption:


without means to resume your wasm code.
Thanks for any type of aid

The paperwork of syscall/js states that js.Value.Get worries when a worth is not a JavaScript item, so you ought to have the ability to “capture the exemption” much like you would certainly recuperate from a panic in various other Go code:

 func tryGet( v js.Value, p string) (outcome js.Value, err mistake) {
postpone func() {
if x:= recuperate(); x!= nil {
var ok bool.
if err, ok = x.( mistake);! okay {
err = fmt.Errorf("% v", x).
return v.Get( p), nil.

Thanks @skillian
However it does not function. The JS phone call exemption does not make the go code panicking, so not recuperation feasible.
The go wasm code just … quits … at the Obtain(" localtorage") line


Most Popular

Recent Comments