bytecodealliance / bytecodealliance/wasmtime
CodegenError should have optional context, rather than pretty-ifying it into a string
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
`pretty_error` should be replaced with methods on `CodegenError` that mutate the error and provide the context that `pretty_error` otherwise adds, and the `CodegenError`'s `Display` impl should print what `pretty_error` creates when it has the necessary context.
These context-adding methods would be similar to how the `wast` crate adds file contents and filename context to errors with these methods:
* https://docs.rs/wast/24.0.0/wast/struct.Error.html#method.set_text
* https://docs.rs/wast/24.0.0/wast/struct.Error.html#method.set_path
Then we can delete `pretty_error`, and avoid using string as an error type in more places (notably in `cranelift-filetests` and its `pretty_anyhow_error` workaround).
Contributor guide
Assessment
This issue has not been assessed yet.