Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Error for ResourceTableError #14

Open
kayhhh opened this issue Jun 16, 2024 · 0 comments
Open

Implement Error for ResourceTableError #14

kayhhh opened this issue Jun 16, 2024 · 0 comments

Comments

@kayhhh
Copy link

kayhhh commented Jun 16, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant