From a3297aebd0e69af1b09718ab6cb0da34a09622b9 Mon Sep 17 00:00:00 2001 From: TechiePi Date: Sun, 9 Oct 2022 02:27:05 +0200 Subject: [PATCH] Fix ``FromResidual`` logic --- ctru-rs/src/error.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) + } } }