aboutsummaryrefslogtreecommitdiff
path: root/src/panic_handler.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-03 22:17:34 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-03 22:17:34 -0800
commit0960f3d6d1b6460e1a7a4dcec4921d2cf664df72 (patch)
tree6928d162d1c2a9fac43fd7fdbc6c9cebb8cfa63c /src/panic_handler.zig
parent64b49ddd951e4e94978497302cd73e8ce8114010 (diff)
downloadbun-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.zig22
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.