Lightpanda: the headless browser designed for AI and automation
let v8 fetch the error name/description
Karl Seguin6dfab2f7fe68
diff --git a/src/browser/js/js.zig b/src/browser/js/js.zigindex d5a52778c..98206bd49 100644--- a/src/browser/js/js.zig+++ b/src/browser/js/js.zig@@ -487,8 +487,7 @@ pub export fn v8_inspector__Client__IMPL__valueSubtype(// Same as valueSubType above, but for the optional description field.// From what I can tell, some drivers _need_ the description field to be// present, even if it's empty. So if we have a subType for the value, we'll-// put an empty description. DOMExceptions get "name: message", which drivers-// use as the error message.+// put an empty description.pub export fn v8_inspector__Client__IMPL__descriptionForValueSubtype(_: *v8.InspectorClientImpl,v8_context: *const v8.Context,@@ -496,21 +495,12 @@ pub export fn v8_inspector__Client__IMPL__descriptionForValueSubtype() callconv(.c) [*c]const u8 {_ = v8_context;- // We _must_ include a non-null description in order for the subtype value- // to be included. Besides that, I don't know if the value has any meaning+ // Without a description, V8 drops the subtype, except for "error": it+ // then describes the value itself ("name: message", plus the stack).const external_entry = Inspector.getTaggedOpaque(c_value) orelse return null;const subtype = external_entry.subtype orelse return null;if (subtype == .@"error") {- const DOMException = @import("../webapi/DOMException.zig");- if (external_entry.as(DOMException)) |ex| {- // copied by the caller before we're called again- const S = struct {- threadlocal var buf: [512]u8 = undefined;- };- const description = std.fmt.bufPrintSentinel(&S.buf, "{s}: {s}", .{ ex.getName(), ex.getMessage() }, 0) catch- std.fmt.bufPrintSentinel(&S.buf, "{s}", .{ex.getName()}, 0) catch return "";- return description.ptr;- }+ return null;}return "";}diff --git a/src/browser/webapi/DOMException.zig b/src/browser/webapi/DOMException.zigindex 755825776..41b9c79cf 100644--- a/src/browser/webapi/DOMException.zig+++ b/src/browser/webapi/DOMException.zig@@ -115,7 +115,7 @@ pub fn getName(self: *const DOMException) []const u8 {};}-pub fn getMessage(self: *const DOMException) []const u8 {+fn getMessage(self: *const DOMException) []const u8 {if (self._custom_message) |msg| {return msg;}