aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Sizeland <[email protected]>2025-02-03 23:08:55 +0000
committerJames Sizeland <[email protected]>2025-02-03 23:08:55 +0000
commitc1671572b4eee06deb51547a98ffa00a7db95652 (patch)
treec1253d44de5b45608293e9512f30f2f298c3436d
parentf03dca3f96806a99adce33f573d4336112077df2 (diff)
improve SpawnError::Busy message
-rw-r--r--embassy-executor/src/spawner.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs
index ce24589bf..7e76a09c6 100644
--- a/embassy-executor/src/spawner.rs
+++ b/embassy-executor/src/spawner.rs
@@ -51,8 +51,7 @@ impl<S> Drop for SpawnToken<S> {
51} 51}
52 52
53/// Error returned when spawning a task. 53/// Error returned when spawning a task.
54#[derive(Copy, Clone, Debug)] 54#[derive(Copy, Clone)]
55#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56pub enum SpawnError { 55pub enum SpawnError {
57 /// Too many instances of this task are already running. 56 /// Too many instances of this task are already running.
58 /// 57 ///
@@ -62,10 +61,25 @@ pub enum SpawnError {
62 Busy, 61 Busy,
63} 62}
64 63
64impl core::fmt::Debug for SpawnError {
65 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
66 core::fmt::Display::fmt(self, f)
67 }
68}
69
65impl core::fmt::Display for SpawnError { 70impl core::fmt::Display for SpawnError {
66 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 71 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67 match self { 72 match self {
68 SpawnError::Busy => write!(f, "Busy"), 73 SpawnError::Busy => write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."),
74 }
75 }
76}
77
78#[cfg(feature = "defmt")]
79impl defmt::Format for SpawnError {
80 fn format(&self, f: defmt::Formatter) {
81 match self {
82 SpawnError::Busy => defmt::write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."),
69 } 83 }
70 } 84 }
71} 85}