diff options
author | 2022-10-23 22:29:23 -0700 | |
---|---|---|
committer | 2022-10-23 22:29:23 -0700 | |
commit | b3434a8b883ee98324cea2c7d14dd988e6bb8adc (patch) | |
tree | 48113b984416cdffb15198dbef60852cad520cf3 /src/bun.js/node/syscall.zig | |
parent | 223ce77ecafe16bf7b314817e06780182dc88c3c (diff) | |
download | bun-b3434a8b883ee98324cea2c7d14dd988e6bb8adc.tar.gz bun-b3434a8b883ee98324cea2c7d14dd988e6bb8adc.tar.zst bun-b3434a8b883ee98324cea2c7d14dd988e6bb8adc.zip |
Add `fd` to `SystemError` and fix 2 cases with invalid tagged union
cc @sno2
Diffstat (limited to 'src/bun.js/node/syscall.zig')
-rw-r--r-- | src/bun.js/node/syscall.zig | 20 |
1 files changed, 20 insertions, 0 deletions
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; } |