go-mod-wasm/wasm/error.go

14 lines
318 B
Go

2021-03-20 12:44:04 +07:00
package wasm
import "syscall/js"
// NewError returns a JS Error with the provided Go error's error message.
func NewError(goErr error) js.Value {
errConstructor, err := Global().Expect(js.TypeFunction, "Error")
if err != nil {
panic("Error constructor not found")
}
return errConstructor.New(goErr.Error())
}