···1010const HANDLE = std_windows.HANDLE;
1111const ULONG_PTR = std_windows.ULONG_PTR;
1212const PVOID = std_windows.PVOID;
1313-const Win32Error = std_windows.Win32Error;
1413const UnexpectedError = std.posix.UnexpectedError;
1514const GetLastError = std_windows.GetLastError;
16151716pub const CloseHandle = std_windows.CloseHandle;
18171918pub fn unexpectedWSAError(err: ws2_32.WinsockError) UnexpectedError {
2020- return std_windows.unexpectedError(@as(Win32Error, @enumFromInt(@intFromEnum(err))));
1919+ @branchHint(.cold);
2020+ // Do NOT route this through std_windows.unexpectedError: it takes a
2121+ // Win32Error and prints it with `{t}` (@tagName). Winsock codes live in the
2222+ // 10000+ range and have no Win32Error tag, so @tagName panics with "invalid
2323+ // enum value". ws2_32.WinsockError is its own exhaustive enum that does have
2424+ // tags for these codes, so format it directly.
2525+ if (std.options.unexpected_error_tracing) {
2626+ std.debug.print("error.Unexpected: WSAGetLastError({d}): {t}\n", .{ @intFromEnum(err), err });
2727+ std.debug.dumpCurrentStackTrace(.{ .first_address = @returnAddress() });
2828+ }
2929+ return error.Unexpected;
2130}
22312332pub fn WSASocketW(