summaryrefslogtreecommitdiff
path: root/src/Messages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 19:57:19 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitd0efcd6d63d8e918d66a1c9493870e78586e9567 (patch)
tree4c8a253bcb61c1227cd44605e46dcdc2e274b0ab /src/Messages.zig
parent4442bf09a377297a33b91066bfb5dd8eedb964f0 (diff)
downloadpardes-d0efcd6d63d8e918d66a1c9493870e78586e9567.tar.gz
pardes-d0efcd6d63d8e918d66a1c9493870e78586e9567.zip
A 9P error past 128 bytes keeps its reason: the path in it gives up its middle to …
An Rerror carries 128 bytes (Plan 9's ERRMAX) and the engine cut longer text there, and a builtin's failure was first clipped between words to 256 with ...: either way the end, which says why, was what went. tree.handle now fits a long reason by cutting the middle of its longest path, else of the whole text, on a character boundary, and reportFailure fills its buffer the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Messages.zig')
-rw-r--r--src/Messages.zig14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index 7342f726..42200863 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -503,18 +503,14 @@ pub fn clip(text: []const u8, max: usize) []const u8 {
/// reportError with the words already chosen.
pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void {
p.fs.failures +%= 1;
- // A builtin a ctl write runs: its first error is also the write's, cut
- // between words.
+ // A builtin a ctl write runs: its first error is also the write's, its
+ // path shortened in the middle if it must be, never its reason.
const failing_write = p.fs.no_prompt or p.fs.capturing or p.fs.write_waits;
if (failing_write and p.fs.failure_len == 0) {
- const kept = if (text.len > p.fs.failure.len) clip(text, p.fs.failure.len - 3) else text;
+ var room: @TypeOf(p.fs.failure) = undefined;
+ const kept = pardes.ctlfs.fitErr(text, &room);
@memcpy(p.fs.failure[0..kept.len], kept);
- var n = kept.len;
- if (kept.len < text.len) {
- @memcpy(p.fs.failure[n..][0..3], "...");
- n += 3;
- }
- p.fs.failure_len = @intCast(n);
+ p.fs.failure_len = @intCast(kept.len);
}
// The write fails with it, and its err record says it: no msg for it,
// so the same failure again is the same record again, counted