Hello everyone! 

First, thank you *all* (I mean this great community) for the Go language 
and especially its support for a wasm target.

As I was attempting to finish up a CL 
(https://go-review.googlesource.com/c/go/+/458395) I found occasion to need 
to great a JS Error based on a Go error. I was hoping to use the JS Error 
constructor that includes an option object to specify a cause and value 
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
 
by using the actual go error. Here's what I was thinking:

readErrCause := js.Global().Get("Object").New()
readErrCause.Set("code", readErr.Error())
readErrCause.Set("value", js.ValueOf(readErr))
readErr := js.Global().Get("Error").New("ReadFull failed", readErrCause)

(where readErr is of the `error` type, of course)

Unfortunately, 
readErrCause.Set("value", js.ValueOf(readErr))

does not work because, as the comment so perfectly says, ValueOf

// Panics if x is not one of the expected types.

I am absolutely up for proposing and implementing a small addition to the 
"js package" if people think it would be helpful but I wanted to check here 
first. 

Again, thank you for all the great work that you *all* do!!

Sincerely,
Will



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c2e513e7-e2de-489b-902b-185a8b1ec2dcn%40googlegroups.com.

Reply via email to