From b82d73557966428ac7db1507bb5a4b800ac6207c Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 4 Jul 2024 23:08:24 +0200 Subject: [PATCH] feat: make zig stack traces optional --- src/thespian.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thespian.zig b/src/thespian.zig index 97d0b45..861a312 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -11,6 +11,8 @@ const c = @cImport({ const cbor = @import("cbor"); const builtin = @import("builtin"); +pub var stack_trace_on_errors: bool = false; + pub const subprocess = if (builtin.os.tag == .windows) @import("subprocess_windows.zig") else @import("subprocess.zig"); pub const install_debugger = c.install_debugger; @@ -204,6 +206,8 @@ pub const message = struct { }; pub fn exit_message(e: anytype, stack_trace: ?*std.builtin.StackTrace) message { + if (!stack_trace_on_errors) + return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable; if (stack_trace) |stack_trace_| { var debug_info_arena_allocator: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer debug_info_arena_allocator.deinit();