1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use super::async_stack_action::AsyncStackAction;
use core::fmt::{self, Display, Formatter};

#[derive(Debug, PartialEq, Eq)]
pub enum CpsError {
    MissingContext,
    UnexpectedAsyncStackAction(Option<AsyncStackAction>),
}

// TODO Implement std::error::Error when it is not `no_std`.

impl Display for CpsError {
    fn fmt(&self, formatter: &mut Formatter) -> Result<(), fmt::Error> {
        match self {
            Self::MissingContext => {
                write!(formatter, "missing context")
            }
            Self::UnexpectedAsyncStackAction(expected) => {
                write!(formatter, "invalid stack action (expected: {expected:?})")
            }
        }
    }
}