Updates stack trace vs error return trace in more places

This commit is contained in:
Mason Remaley
2026-04-11 18:20:26 -07:00
parent ac207073f3
commit 87fb7df257
4 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -3263,7 +3263,7 @@ fn createFoo(param: i32) !Foo {
<ul>
<li>Return an error from main</li>
<li>An error makes its way to {#syntax#}catch unreachable{#endsyntax#} and you have not overridden the default panic handler</li>
<li>Use {#link|errorReturnTrace#} to access the current return trace. You can use {#syntax#}std.debug.dumpStackTrace{#endsyntax#} to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.</li>
<li>Use {#link|errorReturnTrace#} to access the current return trace. You can use {#syntax#}std.debug.dumpErrorReturnTrace{#endsyntax#} to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.</li>
</ul>
{#header_open|Implementation Details#}
<p>
+3 -3
View File
@@ -144,7 +144,7 @@ fn mainServer(init: std.process.Init.Minimal) !void {
error.SkipZigTest => .skip,
else => s: {
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
std.debug.dumpErrorReturnTrace(trace);
}
break :s .fail;
},
@@ -312,7 +312,7 @@ fn mainTerminal(init: std.process.Init.Minimal) void {
std.debug.print("FAIL ({t})\n", .{err});
}
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
std.debug.dumpErrorReturnTrace(trace);
}
test_node.end();
},
@@ -438,7 +438,7 @@ var fuzz_runner: if (builtin.fuzz) struct {
error.SkipZigTest => return,
else => {
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
std.debug.dumpErrorReturnTrace(trace);
}
std.debug.print("failed with error.{t}\n", .{err});
std.process.exit(1);
+2 -2
View File
@@ -442,7 +442,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
@call(.auto, f, args) catch |err| {
std.debug.print("error: {s}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
std.debug.dumpErrorReturnTrace(trace);
}
};
@@ -932,7 +932,7 @@ const WasiThreadImpl = struct {
@call(.auto, f, w.args) catch |err| {
std.debug.print("error: {s}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace);
std.debug.dumpErrorReturnTrace(trace);
}
};
},
+2
View File
@@ -165,6 +165,8 @@ pub const Options = struct {
/// * `debug.dumpCurrentStackTrace`
/// * `debug.writeStackTrace`
/// * `debug.dumpStackTrace`
/// * `debug.writeErrorReturnTrace`
/// * `debug.dumpErrorReturnTrace`
///
/// Stack traces can generally be collected and printed when debug info is stripped, but are
/// often less useful since they usually cannot be mapped to source locations and/or have bad