diff --git a/ctru-rs/src/error.rs b/ctru-rs/src/error.rs index 38841da..9a1657e 100644 --- a/ctru-rs/src/error.rs +++ b/ctru-rs/src/error.rs @@ -29,8 +29,15 @@ impl Try for LibCtruError { } impl FromResidual for LibCtruError { - fn from_residual(_: ::Residual) -> Self { - Self(1) + fn from_residual(e: ::Residual) -> Self { + if let Some(e) = e.err() { + match e { + Error::Os(result) => Self(result), + _ => Self(-1), + } + } else { + Self(-1) + } } }