diff options
author | 2023-10-14 08:51:36 +0800 | |
---|---|---|
committer | 2023-10-13 17:51:36 -0700 | |
commit | d08e112d416ddee7af8d499524e40e7f193ae55a (patch) | |
tree | 8ced72a8d8ff67cbc77afe36bffc5269c3d832c4 /src/bun.js/webcore/blob.zig | |
parent | 77d7e47019753bacc76306dd9066df25c67c51a9 (diff) | |
download | bun-d08e112d416ddee7af8d499524e40e7f193ae55a.tar.gz bun-d08e112d416ddee7af8d499524e40e7f193ae55a.tar.zst bun-d08e112d416ddee7af8d499524e40e7f193ae55a.zip |
fix(error): correct the `path` field in syscall error message. (#6370)
* fix(error): correct the `path` field in syscall error message.
Close: #6336
* fix pathlike union case
Diffstat (limited to 'src/bun.js/webcore/blob.zig')
-rw-r--r-- | src/bun.js/webcore/blob.zig | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 1e0720ea6..f9699cffc 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -1040,7 +1040,10 @@ pub const Blob = struct { break :brk result; }, .err => |err| { - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + return JSC.JSPromise.rejectedPromiseValue( + globalThis, + err.withPath(pathlike.path.slice()).toJSC(globalThis), + ); }, } unreachable; @@ -1080,8 +1083,13 @@ pub const Blob = struct { needs_async.* = true; return .zero; } - - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + if (comptime !needs_open) { + return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + } + return JSC.JSPromise.rejectedPromiseValue( + globalThis, + err.withPath(pathlike.path.slice()).toJSC(globalThis), + ); }, } } @@ -1110,7 +1118,10 @@ pub const Blob = struct { break :brk result; }, .err => |err| { - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + return JSC.JSPromise.rejectedPromiseValue( + globalThis, + err.withPath(pathlike.path.slice()).toJSC(globalThis), + ); }, } unreachable; @@ -1145,7 +1156,13 @@ pub const Blob = struct { needs_async.* = true; return .zero; } - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + if (comptime !needs_open) { + return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); + } + return JSC.JSPromise.rejectedPromiseValue( + globalThis, + err.withPath(pathlike.path.slice()).toJSC(globalThis), + ); }, } } @@ -2289,7 +2306,7 @@ pub const Blob = struct { this.source_fd = 0; } - this.system_error = errno.toSystemError(); + this.system_error = errno.withPath(this.destination_file_store.pathlike.path.slice()).toSystemError(); return AsyncIO.asError(errno.errno); }, }; |