Commit 26c0751
committed
Add
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?try_fail_point!
1 parent 5bc95a1 commit 26c0751
2 files changed
+85
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
| 231 | + | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| |||
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
431 | 459 | | |
432 | 460 | | |
433 | 461 | | |
| |||
843 | 871 | | |
844 | 872 | | |
845 | 873 | | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
846 | 900 | | |
847 | 901 | | |
848 | 902 | | |
| |||
852 | 906 | | |
853 | 907 | | |
854 | 908 | | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
855 | 917 | | |
856 | 918 | | |
857 | 919 | | |
| |||
1032 | 1094 | | |
1033 | 1095 | | |
1034 | 1096 | | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
1035 | 1116 | | |
1036 | 1117 | | |
1037 | 1118 | | |
| |||
0 commit comments