diff options
author | 2022-07-24 01:19:57 -0700 | |
---|---|---|
committer | 2022-07-24 01:22:33 -0700 | |
commit | f524c720958c0e8c81fe846ec2a6a90a3a9b7092 (patch) | |
tree | c83ede75aa7e4fa99f4b1b94b3661874fba46db9 /src/bun.js/javascript.zig | |
parent | b09290b9cb747b853ae0d147afbb95bd08ffb2e7 (diff) | |
download | bun-f524c720958c0e8c81fe846ec2a6a90a3a9b7092.tar.gz bun-f524c720958c0e8c81fe846ec2a6a90a3a9b7092.tar.zst bun-f524c720958c0e8c81fe846ec2a6a90a3a9b7092.zip |
Make errors always print `error:` unless the name of the error is `Error`
Diffstat (limited to '')
-rw-r--r-- | src/bun.js/javascript.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 7c122fe8b..615a2003c 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2081,12 +2081,18 @@ pub const VirtualMachine = struct { fn printErrorNameAndMessage(_: *VirtualMachine, name: ZigString, message: ZigString, comptime Writer: type, writer: Writer, comptime allow_ansi_color: bool) !void { if (name.len > 0 and message.len > 0) { - try writer.print(comptime Output.prettyFmt("<r><red>{s}<r><d>:<r> <b>{s}<r>\n", allow_ansi_color), .{ - name, + const display_name: ZigString = if (!name.is16Bit() and strings.eqlComptime(name.slice(), "Error")) ZigString.init("error") else name; + + try writer.print(comptime Output.prettyFmt("<r><red>{any}<r><d>:<r> <b>{s}<r>\n", allow_ansi_color), .{ + display_name, message, }); } else if (name.len > 0) { - try writer.print(comptime Output.prettyFmt("<r><red>{s}<r>\n", allow_ansi_color), .{name}); + if (name.is16Bit() or !strings.hasPrefixComptime(name.slice(), "error")) { + try writer.print(comptime Output.prettyFmt("<r><red>error<r><d>:<r> <b>{s}<r>\n", allow_ansi_color), .{name}); + } else { + try writer.print(comptime Output.prettyFmt("<r><red>{s}<r>\n", allow_ansi_color), .{name}); + } } else if (message.len > 0) { try writer.print(comptime Output.prettyFmt("<r><red>error<r><d>:<r> <b>{s}<r>\n", allow_ansi_color), .{message}); } else { |