-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In my project I have a ton of code which uses `anyhow::Result`. I want a convenient way to force a function to return a stock error from a failpoint. Today this requires something like: ``` fail::fail_point!("main", true, |msg| { let msg = msg.as_deref().unwrap_or("synthetic error"); Err(anyhow::anyhow!("{msg}")) }); ``` which is cumbersome to copy around. Now, I conservatively made this a new macro. I am not sure how often the use case of a fail point for an infallible (i.e. non-`Result`) function occurs. It may make sense to require those to take a distinct `inject_point!` or something? Signed-off-by: Colin Walters <[email protected]>
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters