From b3434a8b883ee98324cea2c7d14dd988e6bb8adc Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:29:23 -0700 Subject: Add `fd` to `SystemError` and fix 2 cases with invalid tagged union cc @sno2 --- src/bun.js/node/syscall.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/bun.js/node/syscall.zig') diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig index fddd0a8df..c2d13ea59 100644 --- a/src/bun.js/node/syscall.zig +++ b/src/bun.js/node/syscall.zig @@ -565,6 +565,7 @@ pub const Error = struct { errno: Int, syscall: Syscall.Tag = @intToEnum(Syscall.Tag, 0), path: []const u8 = "", + fd: i32 = -1, pub inline fn isRetry(this: *const Error) bool { return this.getErrno() == .AGAIN; @@ -598,6 +599,21 @@ pub const Error = struct { }; } + pub inline fn withFd(this: Error, fd: anytype) Error { + return Error{ + .errno = this.errno, + .syscall = this.syscall, + .fd = @intCast(i32, fd), + }; + } + + pub inline fn withPathLike(this: Error, pathlike: anytype) Error { + return switch (pathlike) { + .fd => |fd| this.withFd(fd), + .path => |path| this.withPath(path.slice()), + }; + } + pub inline fn withSyscall(this: Error, syscall: Syscall) Error { return Error{ .errno = this.errno, @@ -628,6 +644,10 @@ pub const Error = struct { err.path = JSC.ZigString.init(this.path); } + if (this.fd != -1) { + err.fd = this.fd; + } + return err; } -- cgit v1.2.3