diff options
author | 2022-01-03 22:17:34 -0800 | |
---|---|---|
committer | 2022-01-03 22:17:34 -0800 | |
commit | 0960f3d6d1b6460e1a7a4dcec4921d2cf664df72 (patch) | |
tree | 6928d162d1c2a9fac43fd7fdbc6c9cebb8cfa63c /src/panic_handler.zig | |
parent | 64b49ddd951e4e94978497302cd73e8ce8114010 (diff) | |
download | bun-0960f3d6d1b6460e1a7a4dcec4921d2cf664df72.tar.gz bun-0960f3d6d1b6460e1a7a4dcec4921d2cf664df72.tar.zst bun-0960f3d6d1b6460e1a7a4dcec4921d2cf664df72.zip |
Implement a crash reporter and improve some error handling in `bun install`
Diffstat (limited to 'src/panic_handler.zig')
-rw-r--r-- | src/panic_handler.zig | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/panic_handler.zig b/src/panic_handler.zig index 8f3038fa1..d4a65c4a6 100644 --- a/src/panic_handler.zig +++ b/src/panic_handler.zig @@ -11,6 +11,10 @@ const MutableString = _global.MutableString; const stringZ = _global.stringZ; const default_allocator = _global.default_allocator; const C = _global.C; +const CLI = @import("./cli.zig").Cli; +const Features = @import("./analytics/analytics_thread.zig").Features; +const HTTP = @import("http").AsyncHTTP; +const Report = @import("./report.zig"); pub fn NewPanicHandler(comptime panic_func: fn handle_panic(msg: []const u8, error_return_type: ?*std.builtin.StackTrace) noreturn) type { return struct { @@ -30,22 +34,8 @@ pub fn NewPanicHandler(comptime panic_func: fn handle_panic(msg: []const u8, err // This exists to ensure we flush all buffered output before panicking. Output.flush(); - if (msg.len > 0) { - if (Output.isEmojiEnabled()) { - Output.prettyErrorln("<r><red>bun crashed ðŸ˜ðŸ˜ðŸ˜<r><d>: <r><b>{s}<r>\n", .{msg}); - } else { - Output.prettyErrorln("<r><red>Crash<r><d>:<r> <b>{s}<r>", .{msg}); - } - Output.flush(); - } else { - if (Output.isEmojiEnabled()) { - Output.prettyErrorln("<r><red>bun will crash now<r> ðŸ˜ðŸ˜ðŸ˜<r>\n", .{}); - Output.flush(); - } else { - Output.printError("bun has crashed :'(\n", .{}); - } - Output.flush(); - } + Report.fatal(null, msg); + Output.disableBuffering(); // // We want to always inline the panic handler so it doesn't show up in the stacktrace. |