Skip to content

Commit c88e6a7

Browse files
author
Carsten Andrich
committed
add Windows system error codes that map to io::ErrorKind::TimedOut
1 parent bd0bacc commit c88e6a7

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/libstd/io/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ pub enum ErrorKind {
160160
#[stable(feature = "rust1", since = "1.0.0")]
161161
Interrupted,
162162
/// Any I/O error not part of this list.
163+
///
164+
/// Errors that are `Other` now may move to a different or a new
165+
/// [`ErrorKind`] variant in the future. It is not recommended to match
166+
/// an error against `Other` and to expect any additional characteristics,
167+
/// e.g., a specific [`Error::raw_os_error`] return value.
163168
#[stable(feature = "rust1", since = "1.0.0")]
164169
Other,
165170

src/libstd/sys/windows/c.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,26 @@ pub const ERROR_FILE_EXISTS: DWORD = 80;
171171
pub const ERROR_INVALID_PARAMETER: DWORD = 87;
172172
pub const ERROR_BROKEN_PIPE: DWORD = 109;
173173
pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120;
174+
pub const ERROR_SEM_TIMEOUT: DWORD = 121;
174175
pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122;
175176
pub const ERROR_ALREADY_EXISTS: DWORD = 183;
176-
pub const ERROR_NO_DATA: DWORD = 232;
177177
pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203;
178+
pub const ERROR_NO_DATA: DWORD = 232;
179+
pub const ERROR_DRIVER_CANCEL_TIMEOUT: DWORD = 594;
178180
pub const ERROR_OPERATION_ABORTED: DWORD = 995;
179181
pub const ERROR_IO_PENDING: DWORD = 997;
180-
pub const ERROR_TIMEOUT: DWORD = 0x5B4;
182+
pub const ERROR_SERVICE_REQUEST_TIMEOUT: DWORD = 1053;
183+
pub const ERROR_COUNTER_TIMEOUT: DWORD = 1121;
184+
pub const ERROR_TIMEOUT: DWORD = 1460;
185+
pub const ERROR_RESOURCE_CALL_TIMED_OUT: DWORD = 5910;
186+
pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: DWORD = 7012;
187+
pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: DWORD = 7040;
188+
pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: DWORD = 8014;
189+
pub const ERROR_DS_TIMELIMIT_EXCEEDED: DWORD = 8226;
190+
pub const DNS_ERROR_RECORD_TIMED_OUT: DWORD = 9705;
191+
pub const ERROR_IPSEC_IKE_TIMED_OUT: DWORD = 13805;
192+
pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: DWORD = 15402;
193+
pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: DWORD = 15403;
181194

182195
pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT;
183196

src/libstd/sys/windows/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,22 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
6161
c::ERROR_FILE_NOT_FOUND => return ErrorKind::NotFound,
6262
c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound,
6363
c::ERROR_NO_DATA => return ErrorKind::BrokenPipe,
64+
c::ERROR_SEM_TIMEOUT => return ErrorKind::TimedOut,
65+
c::WAIT_TIMEOUT => return ErrorKind::TimedOut,
66+
c::ERROR_DRIVER_CANCEL_TIMEOUT => return ErrorKind::TimedOut,
6467
c::ERROR_OPERATION_ABORTED => return ErrorKind::TimedOut,
68+
c::ERROR_SERVICE_REQUEST_TIMEOUT => return ErrorKind::TimedOut,
69+
c::ERROR_COUNTER_TIMEOUT => return ErrorKind::TimedOut,
70+
c::ERROR_TIMEOUT => return ErrorKind::TimedOut,
71+
c::ERROR_RESOURCE_CALL_TIMED_OUT => return ErrorKind::TimedOut,
72+
c::ERROR_CTX_MODEM_RESPONSE_TIMEOUT => return ErrorKind::TimedOut,
73+
c::ERROR_CTX_CLIENT_QUERY_TIMEOUT => return ErrorKind::TimedOut,
74+
c::FRS_ERR_SYSVOL_POPULATE_TIMEOUT => return ErrorKind::TimedOut,
75+
c::ERROR_DS_TIMELIMIT_EXCEEDED => return ErrorKind::TimedOut,
76+
c::DNS_ERROR_RECORD_TIMED_OUT => return ErrorKind::TimedOut,
77+
c::ERROR_IPSEC_IKE_TIMED_OUT => return ErrorKind::TimedOut,
78+
c::ERROR_RUNLEVEL_SWITCH_TIMEOUT => return ErrorKind::TimedOut,
79+
c::ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT => return ErrorKind::TimedOut,
6580
_ => {}
6681
}
6782

0 commit comments

Comments
 (0)