Open nearest-river opened 9 months ago
It would be great if we could throw exception from rust..
#[deno_bindgen] pub fn div(a: i32,b: i32)-> i32 { if b==0 { deno_bindgen::throw("cannot divide by zero") } else { a/b } }
And an Exception trait would be great just like wasm_bindgen
wasm_bindgen
trait Exception<T> { fn unrwap_or_throw(self)-> T; } impl<T,E> Exception<T> for Result<T,E> {...} impl<T> Exception<T> for Option<T> {...} #[deno_bindgen] pub fn read(path: &str)-> String { std::fs::read_to_string(path).unwrap_or_throw() }
It would be great if we could throw exception from rust..
And an Exception trait would be great just like
wasm_bindgen