Skip to content

Commit

Permalink
Rollup merge of #110433 - ChrisDenton:notfound, r=thomcc
Browse files Browse the repository at this point in the history
Windows: map a few more error codes to ErrorKind

NotFound errors:

* `ERROR_INVALID_DRIVE`: The system cannot find the drive specified
* `ERROR_BAD_NETPATH`: The network path was not found
* `ERROR_BAD_NET_NAME`: The network name cannot be found.

InvalidFilename:

* `ERROR_BAD_PATHNAME`: The specified path is invalid.

Source: [System Error Codes (0-499)](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)
  • Loading branch information
matthiaskrgr authored Apr 17, 2023
2 parents 0a2c0ec + db8dfbd commit 35e6389
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/std/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
c::ERROR_ALREADY_EXISTS => return AlreadyExists,
c::ERROR_FILE_EXISTS => return AlreadyExists,
c::ERROR_BROKEN_PIPE => return BrokenPipe,
c::ERROR_FILE_NOT_FOUND => return NotFound,
c::ERROR_PATH_NOT_FOUND => return NotFound,
c::ERROR_FILE_NOT_FOUND
| c::ERROR_PATH_NOT_FOUND
| c::ERROR_INVALID_DRIVE
| c::ERROR_BAD_NETPATH
| c::ERROR_BAD_NET_NAME => return NotFound,
c::ERROR_NO_DATA => return BrokenPipe,
c::ERROR_INVALID_NAME => return InvalidFilename,
c::ERROR_INVALID_NAME | c::ERROR_BAD_PATHNAME => return InvalidFilename,
c::ERROR_INVALID_PARAMETER => return InvalidInput,
c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return OutOfMemory,
c::ERROR_SEM_TIMEOUT
Expand Down

0 comments on commit 35e6389

Please sign in to comment.