summaryrefslogtreecommitdiff
path: root/src/Messages.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Messages.zig')
-rw-r--r--src/Messages.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index c0838fb2..482ad64d 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -450,10 +450,27 @@ pub const no_pane_slots = "no space for a pane: {d} max";
pub const no_pane_room = "no space for a pane in that column: each keeps its tag and {d} rows";
/// `<operation>: <the error in words>`: FileNotFound reads "file not found".
+/// Why a peer could not be reached, in words, for an error of a 9P dial
+/// (src/9p_io.zig, Client); null for any other error.
+pub fn dialReason(err: anyerror) ?[]const u8 {
+ return switch (err) {
+ error.Dial => "no answer",
+ error.Timeout => "timed out",
+ error.Hangup => "hung up",
+ error.Botch => "protocol botch",
+ else => null,
+ };
+}
+
pub fn reportError(p: *Pardes, id: usize, operation: []const u8, err: anyerror) void {
var buf: [256]u8 = undefined;
var w = std.Io.Writer.fixed(&buf);
w.print("{s}: ", .{operation}) catch {};
+ // A peer out of reach says so, not the error's name (`dial`).
+ if (dialReason(err)) |why| {
+ w.print("dial failed: {s}", .{why}) catch {};
+ return reportFailure(p, id, w.buffered());
+ }
// Every route that opens a pane says the cap the same way.
if (err == error.NoPaneSlots or err == error.NoPaneRoom) {
if (err == error.NoPaneSlots)