-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Explicit constructor from Box<dyn Error + Send + Sync> #83
Comments
use anyhow::anyhow;
fn main() {
let e: Box<dyn std::error::Error + Send + Sync> = unimplemented!();
let e = anyhow!(e);
} |
Reading the docs, doesn't this stringify the error? Won't it lose all the I'd hope it could somehow convert the existing |
Oh, I'm reading through the source code and it seems to be preserving it somehow. Would you mind if I send a PR making such usage clearer in the docs? Also, link from the |
Perhaps I'm missing something but anyhow! isn't very easy to use with
is a bit awkward - I mean:
|
It could be shorter with something_returning_boxed_error().map_err(|e| anyhow!(e))? This would be even slightly more ergonomic if it existed as a function/constructor/method, eg: something_returning_boxed_error().map_err(Anyhow::from_boxed)? But as long as Rust doesn't allow implementing |
Hello
I've noticed there's a (closed) issue about having a
From<Box<dyn Error + Send + Sync>>
impl, that refers to wanting that fromstd
(#66)But would it make sense to have an explicit constructor in the meantime? Eg.
Error::from_box_error(..)
? That way one would have to write some kind ofmap_error(Error::from_box_error)?
instead of just?
, but that's probably better than nothing.The text was updated successfully, but these errors were encountered: