diff options
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index f51409aa..55779c8a 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -715,19 +715,22 @@ pub const Restore = struct { if (comptime pardes.hosted) { const bytes = @import("fs.zig").readRestore(c.p.gpa, path, c.p.settings.dump_dir.get()) catch |err| { var buf: [limits.host_path_cap + 64]u8 = undefined; + var words: [128]u8 = undefined; const why = switch (err) { error.FileNotFound => "no such file", error.PermissionDenied => "permission denied", error.IsDirectory => "a directory, not a dump", - else => @errorName(err), + else => pardes.Messages.errorWords(err, &words), }; return c.p.reportFailure(c.id, std.fmt.bufPrint(&buf, "Restore: {s}: {s}", .{ path, why }) catch "Restore: cannot read the dump"); }; defer c.p.gpa.free(bytes); // Nor does a file that is not a dump, before any warning. - pardes.dump.check(c.p.gpa, bytes) catch |err| { - var buf: [limits.host_path_cap + 64]u8 = undefined; - return c.p.reportFailure(c.id, std.fmt.bufPrint(&buf, "Restore: {s}: not a pardes dump ({s})", .{ path, @errorName(err) }) catch "Restore: not a pardes dump"); + var why_buf: [256]u8 = undefined; + pardes.dump.check(c.p.gpa, bytes, &why_buf) catch |err| { + var buf: [limits.host_path_cap + 320]u8 = undefined; + const why = if (err == error.ParseZon) why_buf[0..std.mem.indexOfScalar(u8, &why_buf, 0).?] else pardes.Messages.errorWords(err, &why_buf); + return c.p.reportFailure(c.id, std.fmt.bufPrint(&buf, "Restore: {s}: not a pardes dump: {s}", .{ path, why }) catch "Restore: not a pardes dump"); }; } // acme's Load adds a dump's windows to the ones there; a Restore |
