Merge pull request #3842 from jamessizeland/improve-spawn-busy-error

improve SpawnError::Busy message
This commit is contained in:
Dario Nieuwenhuis 2025-02-03 23:34:53 +00:00 committed by GitHub
commit 2c8a550410
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,8 +51,7 @@ impl<S> Drop for SpawnToken<S> {
}
/// Error returned when spawning a task.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Copy, Clone)]
pub enum SpawnError {
/// Too many instances of this task are already running.
///
@ -62,10 +61,25 @@ pub enum SpawnError {
Busy,
}
impl core::fmt::Debug for SpawnError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::fmt::Display::fmt(self, f)
}
}
impl core::fmt::Display for SpawnError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
SpawnError::Busy => write!(f, "Busy"),
SpawnError::Busy => write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for SpawnError {
fn format(&self, f: defmt::Formatter) {
match self {
SpawnError::Busy => defmt::write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."),
}
}
}