blob: 6753d9203ed18cfae77d0427617dfd2ca85fcdc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
--- exercises/024_errors4.zig 2023-10-03 22:15:22.122241138 +0200
+++ answers/024_errors4.zig 2023-10-05 20:04:06.949431550 +0200
@@ -59,7 +59,13 @@
// If we get a TooSmall error, we should return 10.
// If we get any other error, we should return that error.
// Otherwise, we return the u32 number.
- return detectProblems(n) ???;
+ return detectProblems(n) catch |err| {
+ if (err == MyNumberError.TooSmall) {
+ return 10;
+ }
+
+ return err;
+ };
}
fn detectProblems(n: u32) MyNumberError!u32 {
|