✓
Passing This code compiles and runs correctly.
Code
// Test 832: Deep error handling
//
// Real apps handle errors at every level.
// This tests that error branches work correctly when deeply nested.
const std = @import("std");
~tor step1 {}
| ok i32
| failed string
~tor step2 { value: i32 }
| ok i32
| failed string
~tor step3 { value: i32 }
| ok i32
| failed string
~tor step4 { value: i32 }
| ok i32
| failed string
~tor log { msg: string }
~proc step1|zig {
return .{ .@"ok" = 1 };
}
~proc step2|zig {
if (value < 0) {
return .{ .@"failed" = "step2 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc step3|zig {
if (value < 0) {
return .{ .@"failed" = "step3 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc step4|zig {
if (value < 0) {
return .{ .@"failed" = "step4 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc log|zig {
std.debug.print("{s}\n", .{msg});
}
// 4 levels deep with error handling at each level
~step1()
| ok s1 |> step2(value: s1)
| ok s2 |> step3(value: s2)
| ok s3 |> step4(value: s3)
| ok _ |> log(msg: "Success!")
| failed f |> log(msg: f)
| failed f |> log(msg: f)
| failed f |> log(msg: f)
| failed f |> log(msg: f)
Stdout must contain:
Success!Flows
flow ~step1 click a branch to expand · @labels scroll to their anchor
step1