When building for web, ResourceTable becomes annoying to use because the error type is not compatible with anyhow:
the trait `StdError` is not implemented for `ResourceTableError`, which is required by `Result<(), anyhow::Error>: FromResidual<Result<Infallible, ResourceTableError>>
So for example when implementing host functions, you must map_err every table error:
fn remove_node(&mut self, value: Resource<Node>) -> wasm_bridge::Result<()> {
let rep = value.rep();
self.table.delete(value).map_err(|e| anyhow!("{:?}", e))?;
}
When building for native, that line would simply be:
self.table.delete(value)?;
I would be happy to make a PR if you want as this shouldn't be difficult, just wasn't sure how you would want to go about it (for example using the thiserror crate).
When building for web,
ResourceTablebecomes annoying to use because the error type is not compatible with anyhow:So for example when implementing host functions, you must
map_errevery table error:When building for native, that line would simply be:
I would be happy to make a PR if you want as this shouldn't be difficult, just wasn't sure how you would want to go about it (for example using the
thiserrorcrate).