wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Allow using `?` with `Result<T, JsValue>` in functions that return `Result<S, Box<dyn std::error::Error>>`

Open casey opened this issue 3 years ago • 0 comments

Motivation

For quick and dirty error handling, it's often nice to use Box<dyn std::error::Error>. This doesn't work well with wasm-bindgen, however, because JsValue doesn't implement std::error::Error

Proposed Solution

Implement std::error::Error for JsValue. Although JsValue might not always be an error, it is wasm-bindgen's error type.

Alternatives

Do nothing.

casey avatar Jul 14 '22 22:07 casey