✓
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");
~event step1 {}
| ok i32
| failed []const u8
~event step2 { value: i32 }
| ok i32
| failed []const u8
~event step3 { value: i32 }
| ok i32
| failed []const u8
~event step4 { value: i32 }
| ok i32
| failed []const u8
~event log { msg: []const u8 }
| done
~proc step1 {
return .{ .@"ok" = 1 };
}
~proc step2 {
if (value < 0) {
return .{ .@"failed" = "step2 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc step3 {
if (value < 0) {
return .{ .@"failed" = "step3 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc step4 {
if (value < 0) {
return .{ .@"failed" = "step4 failed" };
}
return .{ .@"ok" = value + 1 };
}
~proc log {
std.debug.print("{s}\n", .{msg});
return .{ .@"done" = .{} };
}
// 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!")
| done |> _
| failed f |> log(msg: f)
| done |> _
| failed f |> log(msg: f)
| done |> _
| failed f |> log(msg: f)
| done |> _
| failed f |> log(msg: f)
| done |> _
Test Configuration
Expected Behavior:
STDOUT_CONTAINS:Success!