╭ change_panic_handler ─────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1 #update=initial version 2 #file=main.zig 3 pub fn main() !u8 { 4 var a: u8 = undefined; 5 a = 255; 6 _ = a + 1; 7 return 1; 8 } 9 pub const panic = std.debug.FullPanic(myPanic); 10 fn myPanic(msg: []const u8, _: ?usize) noreturn { 11 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); 12 stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {}; 13 std.process.exit(0); 14 } 15 const std = @import("std"); 16 const io = std.Io.Threaded.global_single_threaded.io(); 17 #expect_stdout="panic message: integer overflow\n" 18 19 #update=change the panic handler body 20 #file=main.zig 21 pub fn main() !u8 { 22 var a: u8 = undefined; 23 a = 255; 24 _ = a + 1; 25 return 1; 26 } 27 pub const panic = std.debug.FullPanic(myPanic); 28 fn myPanic(msg: []const u8, _: ?usize) noreturn { 29 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); 30 stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {}; 31 std.process.exit(0); 32 } 33 const std = @import("std"); 34 const io = std.Io.Threaded.global_single_threaded.io(); 35 #expect_stdout="new panic message: integer overflow\n" 36 37 #update=change the panic handler function value 38 #file=main.zig 39 pub fn main() !u8 { 40 var a: u8 = undefined; 41 a = 255; 42 _ = a + 1; 43 return 1; 44 } 45 pub const panic = std.debug.FullPanic(myPanicNew); 46 fn myPanicNew(msg: []const u8, _: ?usize) noreturn { 47 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); 48 stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {}; 49 std.process.exit(0); 50 } 51 const std = @import("std"); 52 const io = std.Io.Threaded.global_single_threaded.io(); 53 #expect_stdout="third panic message: integer overflow\n" 54