From 7aabaafbb4667cbe2b709d2d85dacf6d7fe261ea Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Mon, 30 Dec 2024 13:18:56 -0800 Subject: [PATCH] clean up some errors --- src/install/patch_install.zig | 39 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/install/patch_install.zig b/src/install/patch_install.zig index c6b3ce055d..e5c4326ef3 100644 --- a/src/install/patch_install.zig +++ b/src/install/patch_install.zig @@ -425,20 +425,25 @@ pub const PatchTask = struct { const stat: bun.Stat = switch (bun.sys.stat(absolute_patchfile_path)) { .err => |e| { if (e.getErrno() == bun.C.E.NOENT) { - const fmt = "\n\nerror: could not find patch file {s}\n\nPlease make sure it exists.\n\nTo create a new patch file run:\n\n bun patch {s}\n"; - const args = .{ + log.addErrorFmt(null, Loc.Empty, this.manager.allocator, + \\Could not find patch file '{s}' + \\ + \\To create a new patch file run: + \\ + \\ bun patch {s} + , .{ this.callback.calc_hash.patchfile_path, this.manager.lockfile.patched_dependencies.get(this.callback.calc_hash.name_and_version_hash).?.path.slice(this.manager.lockfile.buffers.string_bytes.items), - }; - log.addErrorFmt(null, Loc.Empty, this.manager.allocator, fmt, args) catch bun.outOfMemory(); + }) catch bun.outOfMemory(); return null; } - log.addWarningFmt( + + log.addErrorFmt( null, Loc.Empty, this.manager.allocator, - "patchfile {s} is empty, please restore or delete it.", - .{absolute_patchfile_path}, + "{s} - Failed to stat patch file '{s}'", + .{ @tagName(e.getErrno()), absolute_patchfile_path }, ) catch bun.outOfMemory(); return null; }, @@ -450,8 +455,16 @@ pub const PatchTask = struct { null, Loc.Empty, this.manager.allocator, - "patchfile {s} is empty, plese restore or delete it.", - .{absolute_patchfile_path}, + \\Patch file '{s}' is empty. + \\ + \\To create a new patch file run: + \\ + \\ bun patch {s} + , + .{ + absolute_patchfile_path, + this.manager.lockfile.patched_dependencies.get(this.callback.calc_hash.name_and_version_hash).?.path.slice(this.manager.lockfile.buffers.string_bytes.items), + }, ) catch bun.outOfMemory(); return null; } @@ -462,8 +475,8 @@ pub const PatchTask = struct { null, Loc.Empty, this.manager.allocator, - "failed to open patch file: {}", - .{e}, + "{s} - Failed to open patch file '{s}'", + .{ @tagName(e.getErrno()), absolute_patchfile_path }, ) catch bun.outOfMemory(); return null; }, @@ -487,8 +500,8 @@ pub const PatchTask = struct { null, Loc.Empty, this.manager.allocator, - "failed to read from patch file: {} ({s})", - .{ e, absolute_patchfile_path }, + "{s} - Failed to read patch file '{s}'", + .{ @tagName(e.getErrno()), absolute_patchfile_path }, ) catch bun.outOfMemory(); return null; },