Skip to content

Implement Error for ResourceTableError #14

@k-43

Description

@k-43

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions