Motor OS: make decode_error_kind more comprehensive

This commit is contained in:
U. Lasiotus 2025-11-24 21:17:05 -08:00
parent c871d09d1c
commit e1a805a68e
2 changed files with 21 additions and 10 deletions

View file

@ -175,9 +175,9 @@ dependencies = [
[[package]]
name = "moto-rt"
version = "0.15.0"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058a2807a30527bee4c30df7ababe971cdde94372d4dbd1ff145bb403381436c"
checksum = "0bf4bc387d3b3502cb92c09ec980cca909b94978e144c61da8319ecf4bc8d031"
dependencies = [
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",

View file

@ -58,16 +58,27 @@ pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind {
}
match code as moto_rt::ErrorCode /* u16 */ {
E_ALREADY_IN_USE => ErrorKind::AlreadyExists,
E_INVALID_FILENAME => ErrorKind::InvalidFilename,
E_NOT_FOUND => ErrorKind::NotFound,
E_TIMED_OUT => ErrorKind::TimedOut,
E_NOT_IMPLEMENTED => ErrorKind::Unsupported,
E_FILE_TOO_LARGE => ErrorKind::FileTooLarge,
E_UNEXPECTED_EOF => ErrorKind::UnexpectedEof,
E_INVALID_ARGUMENT => ErrorKind::InvalidInput,
E_UNSPECIFIED => ErrorKind::Uncategorized,
E_UNKNOWN => ErrorKind::Uncategorized,
E_NOT_READY => ErrorKind::WouldBlock,
E_NOT_IMPLEMENTED => ErrorKind::Unsupported,
E_VERSION_TOO_HIGH => ErrorKind::Unsupported,
E_VERSION_TOO_LOW => ErrorKind::Unsupported,
E_INVALID_ARGUMENT => ErrorKind::InvalidInput,
E_OUT_OF_MEMORY => ErrorKind::OutOfMemory,
E_NOT_ALLOWED => ErrorKind::PermissionDenied,
E_NOT_FOUND => ErrorKind::NotFound,
E_INTERNAL_ERROR => ErrorKind::Other,
E_TIMED_OUT => ErrorKind::TimedOut,
E_ALREADY_IN_USE => ErrorKind::AlreadyExists,
E_UNEXPECTED_EOF => ErrorKind::UnexpectedEof,
E_INVALID_FILENAME => ErrorKind::InvalidFilename,
E_NOT_A_DIRECTORY => ErrorKind::NotADirectory,
E_BAD_HANDLE => ErrorKind::InvalidInput,
E_FILE_TOO_LARGE => ErrorKind::FileTooLarge,
E_NOT_CONNECTED => ErrorKind::NotConnected,
E_STORAGE_FULL => ErrorKind::StorageFull,
E_INVALID_DATA => ErrorKind::InvalidData,
_ => crate::io::ErrorKind::Uncategorized,
}
}