This commit is contained in:
2026-06-04 02:06:57 +02:00
parent a26eca2a63
commit 77e39463d4
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -59,7 +59,12 @@ fn fixTooSmall(n: u32) MyNumberError!u32 {
// 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 {
+1 -1
View File
@@ -26,7 +26,7 @@ fn addFive(n: u32) MyNumberError!u32 {
// This function needs to return any error which might come back from detect().
// Please use a "try" statement rather than a "catch".
//
const x = detect(n);
const x = try detect(n);
return x + 5;
}