aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/node
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/node')
-rw-r--r--src/bun.js/node/syscall.zig20
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;
}