dom_exception: adapt to interface definition change

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2023-11-27 16:44:26 +01:00
parent 86489f3635
commit 0ba0ae5b4e

View File

@@ -44,9 +44,10 @@ pub const DOMException = struct {
pub const _DATA_CLONE_ERR = 25;
// TODO: deinit
pub fn init(alloc: std.mem.Allocator, err: parser.DOMError, callerName: []const u8) anyerror!DOMException {
const errName = DOMException.name(err);
const str = switch (err) {
pub fn init(alloc: std.mem.Allocator, err: anyerror, callerName: []const u8) anyerror!DOMException {
const errCast = @as(parser.DOMError, @errSetCast(err));
const errName = DOMException.name(errCast);
const str = switch (errCast) {
error.HierarchyRequest => try allocPrint(
alloc,
"{s}: Failed to execute '{s}' on 'Node': The new child element contains the parent.",
@@ -55,7 +56,7 @@ pub const DOMException = struct {
error.NoError => unreachable,
else => "", // TODO: implement other messages
};
return .{ .err = err, .str = str };
return .{ .err = errCast, .str = str };
}
fn name(err: parser.DOMError) []const u8 {