improve event's log result

This commit is contained in:
Pierre Tachoire
2024-11-18 13:13:52 +01:00
parent 0788e22dd5
commit f6ad95c647
2 changed files with 7 additions and 3 deletions

View File

@@ -251,12 +251,12 @@ pub const EventHandler = struct {
Event.toInterface(evt) catch unreachable,
}, &res) catch |e| log.err("event handler error: {any}", .{e});
} else {
data.cbk.trycall(.{event}, &res) catch |e| log.err("event handler error: {any}", .{e});
data.cbk.trycall(.{event}, &res) catch |e| log.err("event handler error (null event): {any}", .{e});
}
// in case of function error, we log the result and the trace.
if (!res.success) {
log.info("event handler error: {s}", .{res.result orelse "unknown"});
log.info("event handler error try catch: {s}", .{res.result orelse "unknown"});
log.debug("{s}", .{res.stack orelse "no stack trace"});
}
}

View File

@@ -382,7 +382,11 @@ pub const XMLHttpRequest = struct {
self.reset(alloc);
self.url = try alloc.dupe(u8, url);
self.uri = std.Uri.parse(self.url.?) catch return DOMError.Syntax;
self.uri = std.Uri.parse(self.url.?) catch |err| {
log.debug("parse url ({s}): {any}", .{ self.url.?, err });
return DOMError.Syntax;
};
log.debug("open url ({s})", .{self.url.?});
self.sync = if (asyn) |b| !b else false;
self.state = OPENED;