You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
Feature request: in failure_derive, add an option to fail attribute that would automatically generate a Debug implementation that is identical to (or, perhaps more appropriately, delegating to) the Display implementation (as generated by #[fail(display=...)]).
Context:
I am defining my own Fail types, for example:
#[derive(Fail)]#[fail(display = "Aborting by user request")]pubstructAbortedByUser;
I am also using fn main() -> Result<(), failure::Error>. This means that the std::process::Termination trait comes into play, and its implementation for Result ends up calling eprintln!("Error: {:?}", err);. If I derive Debug for my type, I get the output Error: AbortedByUser, which is not ideal UX-wise. So I ended up doing this:
Now the program prints: Error: Aborting by user request.
This was fine while I only had one such failure type, but then I added the second one for which I wanted the same kind of reporting experience. Obviously, I can remove most of the boilerpaste with a macro, but that's still a macro that I'd have to write and put somewhere in my code. It would be much nicer if I could just write something like #[fail(display = "Aborting by user request", debug_as_display)].
The text was updated successfully, but these errors were encountered:
Feature request: in failure_derive, add an option to
fail
attribute that would automatically generate a Debug implementation that is identical to (or, perhaps more appropriately, delegating to) the Display implementation (as generated by#[fail(display=...)]
).Context:
I am defining my own Fail types, for example:
I am also using
fn main() -> Result<(), failure::Error>
. This means that thestd::process::Termination
trait comes into play, and its implementation for Result ends up callingeprintln!("Error: {:?}", err);
. If I derive Debug for my type, I get the outputError: AbortedByUser
, which is not ideal UX-wise. So I ended up doing this:Now the program prints:
Error: Aborting by user request
.This was fine while I only had one such failure type, but then I added the second one for which I wanted the same kind of reporting experience. Obviously, I can remove most of the boilerpaste with a macro, but that's still a macro that I'd have to write and put somewhere in my code. It would be much nicer if I could just write something like
#[fail(display = "Aborting by user request", debug_as_display)]
.The text was updated successfully, but these errors were encountered: