|
|
|
|
|
by tison
160 days ago
|
|
I think they are almost compatible. `thiserror` helps you define the error type. That error type can then be used with `anyhow` or `exn`. Actually, we have been using thiserror + exn for a long time, and it works well. While later we realize that `struct ModuleError(String)` can easily implement Error without thiserror, we remove thiserror dependency for conciseness. `exn` can use `anyhow::Error` as its inner Error. However, one may use `Exn::as_error` to retrieve the outermost error layer to populate anyhow. I ever consider `impl std::error::Error` for `exn::Exn,` but it would lose some information, especially if the error has multiple children. `error-stack` did that at the cost of no more source: * https://docs.rs/error-stack/0.6.0/src/error_stack/report.rs.... * https://docs.rs/error-stack/0.6.0/src/error_stack/error.rs.h... |
|