diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 05:04:57 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 05:18:09 -0300 |
| commit | 51ddaaf3917ad7968df877d10580d1eadb926688 (patch) | |
| tree | bedad9f6f2c1b04a34c76599ed126fc61b2b5ac9 /src/builtins.zig | |
| parent | 250db41743f77ce3d8421f729bdea0065aa6bc79 (diff) | |
| download | pardes-51ddaaf3917ad7968df877d10580d1eadb926688.tar.gz pardes-51ddaaf3917ad7968df877d10580d1eadb926688.zip | |
Restore and ThemeFile failures say why in words, a ZON one with its line: never FileTooLarge, ParseZon or a bare `parse zon`
Restore read failures named the Zig error (FileTooLarge, NotAFile,
ReadFailed), a file that is no dump said `not a pardes dump (ParseZon)`,
and a ThemeFile that did not parse said `parse zon`. Messages.errorWords
says an error in words (the few that read badly spelled out plainly,
the rest spaced and lower case, as reportError did), and zonWhy gives
the parser's first error with its line: `not a pardes dump: line 1:
expected ...`, `theme file x.zon: line 3: ...`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 |
