Browse Source

Standardise error strings

pull/94/head
Andrea Ciliberti 2 years ago
parent
commit
3285871fb7
  1. 14
      ctru-rs/src/error.rs
  2. 8
      ctru-rs/src/services/ndsp/mod.rs

14
ctru-rs/src/error.rs

@ -104,9 +104,9 @@ impl fmt::Debug for Error { @@ -104,9 +104,9 @@ impl fmt::Debug for Error {
Self::ServiceAlreadyActive => f.debug_tuple("ServiceAlreadyActive").finish(),
Self::OutputAlreadyRedirected => f.debug_tuple("OutputAlreadyRedirected").finish(),
Self::BufferTooShort(provided, wanted) => f
.debug_tuple("BufferTooShort")
.field(provided)
.field(wanted)
.debug_struct("BufferTooShort")
.field("provided", provided)
.field("wanted", wanted)
.finish(),
}
}
@ -117,18 +117,18 @@ impl fmt::Display for Error { @@ -117,18 +117,18 @@ impl fmt::Display for Error {
match self {
&Self::Os(err) => write!(
f,
"Libctru result code 0x{err:08X}: [{} {}] {}: {}",
"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::ServiceAlreadyActive => write!(f, "service already active"),
Self::OutputAlreadyRedirected => {
write!(f, "Output streams are already redirected to 3dslink")
write!(f, "output streams are already redirected to 3dslink")
}
Self::BufferTooShort(provided, wanted) => write!(f, "The provided buffer's length is too short (length = {provided}) to hold the wanted data (size = {wanted})")
Self::BufferTooShort(provided, wanted) => write!(f, "the provided buffer's length is too short (length = {provided}) to hold the wanted data (size = {wanted})")
}
}
}

8
ctru-rs/src/services/ndsp/mod.rs

@ -317,10 +317,10 @@ impl AudioFormat { @@ -317,10 +317,10 @@ impl AudioFormat {
impl fmt::Display for NdspError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::InvalidChannel(id) => write!(f, "Audio Channel with ID {id} doesn't exist. Valid channels have an ID between 0 and 23."),
Self::ChannelAlreadyInUse(id) => write!(f, "Audio Channel with ID {id} is already being used. Drop the other instance if you want to use it here."),
Self::WaveBusy(id) => write!(f, "The selected WaveInfo is busy playing on channel {id}."),
Self::SampleCountOutOfBounds(samples_requested, max_samples) => write!(f, "The sample count requested is too big. Requested amount was {samples_requested} while the maximum sample count is {max_samples}."),
Self::InvalidChannel(id) => write!(f, "audio Channel with ID {id} doesn't exist. Valid channels have an ID between 0 and 23"),
Self::ChannelAlreadyInUse(id) => write!(f, "audio Channel with ID {id} is already being used. Drop the other instance if you want to use it here"),
Self::WaveBusy(id) => write!(f, "the selected WaveInfo is busy playing on channel {id}"),
Self::SampleCountOutOfBounds(samples_requested, max_samples) => write!(f, "the sample count requested is too big (requested = {samples_requested}, maximum = {max_samples})"),
}
}
}

Loading…
Cancel
Save