std-docs: improve error message on write failure

This commit is contained in:
Isaac Freund 2025-08-15 19:12:40 +02:00
parent 4fcdb08390
commit ce4e8a991f
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -106,9 +106,19 @@ fn accept(context: *Context, connection: std.net.Server.Connection) void {
return;
},
};
serveRequest(&request, context) catch |err| {
std.log.err("unable to serve {s}: {s}", .{ request.head.target, @errorName(err) });
return;
serveRequest(&request, context) catch |err| switch (err) {
error.WriteFailed => {
if (conn_writer.err) |e| {
std.log.err("unable to serve {s}: {s}", .{ request.head.target, @errorName(e) });
} else {
std.log.err("unable to serve {s}: {s}", .{ request.head.target, @errorName(err) });
}
return;
},
else => {
std.log.err("unable to serve {s}: {s}", .{ request.head.target, @errorName(err) });
return;
},
};
}
}