Function panicExtra [src]

Equivalent to @panic but with a formatted message, and with an explicitly provided return address.

Prototype

pub fn panicExtra( ret_addr: ?usize, comptime format: []const u8, args: anytype, ) noreturn

Parameters

ret_addr: ?usizeformat: []const u8

Source

pub fn panicExtra( ret_addr: ?usize, comptime format: []const u8, args: anytype, ) noreturn { @branchHint(.cold); const size = 0x1000; const trunc_msg = "(msg truncated)"; var buf: [size + trunc_msg.len]u8 = undefined; var bw: Writer = .fixed(buf[0..size]); // a minor annoyance with this is that it will result in the NoSpaceLeft // error being part of the @panic stack trace (but that error should // only happen rarely) const msg = if (bw.print(format, args)) |_| bw.buffered() else |_| blk: { @memcpy(buf[size..], trunc_msg); break :blk &buf; }; std.builtin.panic.call(msg, ret_addr); }