I’m working with nonblocking datagram file sockets on an embedded yocto Linux platform. In this configuration, calling sendto on a socket file that doesn’t exist can sometimes set errno to 2 (file not found), and sometimes 111 (connection refused).
error.ConnectionRefused, is not in the error set for std.posix.sendto, so when sendto triggers that error, I get an unexpected error and a stack trace printout from Zig.
I can handle the error just fine.
Is there anything I can do to silence the printing from my debug builds, besides patching the standard library?
error.Unexpected is always indicative of a bug in the standard library; system error codes that trigger error.Unexpected should be handled once they are known to be possible.
(note also that the debug printing only happens in Debug mode)
I am confused about your reproduction, though. std.posix.sendto handles ENOENT and ECONNREFUSED. Could you provide exactly the error.Unexpected debug printing you’re hitting / the full reproduction?