pen_ffi/cps/
error.rs

1use super::async_stack_action::AsyncStackAction;
2use core::fmt::{self, Display, Formatter};
3
4#[derive(Debug, PartialEq, Eq)]
5pub enum CpsError {
6    MissingContext,
7    UnexpectedAsyncStackAction(Option<AsyncStackAction>),
8}
9
10// TODO Implement std::error::Error when it is not `no_std`.
11
12impl Display for CpsError {
13    fn fmt(&self, formatter: &mut Formatter) -> Result<(), fmt::Error> {
14        match self {
15            Self::MissingContext => {
16                write!(formatter, "missing context")
17            }
18            Self::UnexpectedAsyncStackAction(expected) => {
19                write!(formatter, "invalid stack action (expected: {expected:?})")
20            }
21        }
22    }
23}