From 21d8017980b170e92a2c197096149c1d2ecbd6c9 Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Sat, 28 Jan 2023 14:16:31 -0800 Subject: [PATCH 1/2] Use the human-readable error strings in the Error Display impl --- ctru-rs/src/error.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ctru-rs/src/error.rs b/ctru-rs/src/error.rs index bdd2d2e..9aaf410 100644 --- a/ctru-rs/src/error.rs +++ b/ctru-rs/src/error.rs @@ -101,13 +101,17 @@ impl fmt::Debug for Error { } } -// TODO: Expand libctru result code into human-readable error message. These should be useful: -// https://www.3dbrew.org/wiki/Error_codes -// https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/result.h impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - &Self::Os(err) => write!(f, "libctru result code: 0x{err:08X}"), + &Self::Os(err) => write!( + f, + "libctru result code 0x{err:08X}: [{} {}] {}: {}", + result_code_level_str(err), + result_code_module_str(err), + result_code_summary_str(err), + result_code_description_str(err) + ), Self::Libc(err) => write!(f, "{err}"), Self::ServiceAlreadyActive => write!(f, "Service already active"), Self::OutputAlreadyRedirected => { @@ -135,7 +139,7 @@ fn result_code_level_str(result: ctru_sys::Result) -> Cow<'static, str> { RL_PERMANENT => "permanent", RL_TEMPORARY => "temporary", RL_STATUS => "status", - code => return Cow::Owned(format!("(unknown: {code:#x})")), + code => return Cow::Owned(format!("(unknown level: {code:#x})")), }) } @@ -160,7 +164,7 @@ fn result_code_summary_str(result: ctru_sys::Result) -> Cow<'static, str> { RS_STATUSCHANGED => "status_changed", RS_INTERNAL => "internal", RS_INVALIDRESVAL => "invalid_res_val", - code => return Cow::Owned(format!("(unknown: {code:#x})")), + code => return Cow::Owned(format!("(unknown summary: {code:#x})")), }) } @@ -200,7 +204,7 @@ fn result_code_description_str(result: ctru_sys::Result) -> Cow<'static, str> { RD_NOT_AUTHORIZED => "not_authorized", RD_TOO_LARGE => "too_large", RD_INVALID_SELECTION => "invalid_selection", - code => return Cow::Owned(format!("(unknown: {code:#x})")), + code => return Cow::Owned(format!("(unknown description: {code:#x})")), }) } @@ -317,6 +321,6 @@ fn result_code_module_str(result: ctru_sys::Result) -> Cow<'static, str> { RM_NFP => "nfp", RM_APPLICATION => "application", RM_INVALIDRESVAL => "invalid_res_val", - code => return Cow::Owned(format!("(unknown: {code:#x})")), + code => return Cow::Owned(format!("(unknown module: {code:#x})")), }) } From 6629a6dc1f321b1ca9a51a2d9e2f39625b6893c4 Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Sat, 28 Jan 2023 14:35:11 -0800 Subject: [PATCH 2/2] Try bumping CI nightly version to fix error --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ccd74a..102c704 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: matrix: toolchain: # Run against a "known good" nightly - - nightly-2022-07-18 + - nightly-2023-01-13 # Check for breakage on latest nightly - nightly # But if latest nightly fails, allow the workflow to continue