diff --git a/ctru-rs/src/error.rs b/ctru-rs/src/error.rs index bd9c222..53c3fbe 100644 --- a/ctru-rs/src/error.rs +++ b/ctru-rs/src/error.rs @@ -6,12 +6,13 @@ use ctru_sys::result::{R_DESCRIPTION, R_LEVEL, R_MODULE, R_SUMMARY}; pub type Result = ::std::result::Result; /// The error type returned by all libctru functions. +#[non_exhaustive] pub enum Error { - Os(i32), + Os(ctru_sys::Result), } -impl From for Error { - fn from(err: i32) -> Self { +impl From for Error { + fn from(err: ctru_sys::Result) -> Self { Error::Os(err) } } @@ -19,15 +20,14 @@ impl From for Error { impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Error::Os(err) => { - write!(f, "libctru result code: {:08X}:", err)?; - f.debug_struct("") - .field("description", &R_DESCRIPTION(err)) - .field("module", &R_MODULE(err)) - .field("summary", &R_SUMMARY(err)) - .field("level", &R_LEVEL(err)) - .finish() - } + Error::Os(err) => f + .debug_struct("Error") + .field("raw", &format_args!("{:#08X}", err)) + .field("description", &R_DESCRIPTION(err)) + .field("module", &R_MODULE(err)) + .field("summary", &R_SUMMARY(err)) + .field("level", &R_LEVEL(err)) + .finish(), } } }