mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
Updates stack trace vs error return trace in more places
This commit is contained in:
+1
-1
@@ -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>
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user