fastGet can throw (#19506)

Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
pfg
2025-05-14 22:14:20 -07:00
committed by GitHub
parent 6090833da6
commit a7b46ebbfe
20 changed files with 93 additions and 92 deletions

View File

@@ -1237,7 +1237,7 @@ pub const Formatter = struct {
if (js_type.canGet() and js_type != .ProxyObject and !opts.disable_inspect_custom) {
// Attempt to get custom formatter
if (value.fastGet(globalThis, .inspectCustom)) |callback_value| {
if (value.fastGet(globalThis, .inspectCustom) catch return .{ .tag = .RevokedProxy }) |callback_value| {
if (callback_value.isCallable()) {
return .{
.tag = .{
@@ -1250,7 +1250,6 @@ pub const Formatter = struct {
};
}
}
if (globalThis.hasException()) return .{ .tag = .RevokedProxy };
}
if (js_type == .DOMWrapper) {
@@ -2939,7 +2938,7 @@ pub const Formatter = struct {
},
}
if (value.fastGet(this.globalThis, .message)) |message_value| {
if (try value.fastGet(this.globalThis, .message)) |message_value| {
if (message_value.isString()) {
if (!this.single_line) {
this.writeIndent(Writer, writer_) catch unreachable;
@@ -2973,7 +2972,7 @@ pub const Formatter = struct {
comptime Output.prettyFmt("<r><blue>data<d>:<r> ", enable_ansi_colors),
.{},
);
const data = value.fastGet(this.globalThis, .data) orelse JSValue.undefined;
const data = (try value.fastGet(this.globalThis, .data)) orelse JSValue.undefined;
const tag = Tag.getAdvanced(data, this.globalThis, .{
.hide_global = true,
.disable_inspect_custom = this.disable_inspect_custom,
@@ -2986,7 +2985,7 @@ pub const Formatter = struct {
}
},
.ErrorEvent => {
if (value.fastGet(this.globalThis, .@"error")) |error_value| {
if (try value.fastGet(this.globalThis, .@"error")) |error_value| {
if (!this.single_line) {
this.writeIndent(Writer, writer_) catch unreachable;
}