Skip to main content

kovan_stm/
errors.rs

1use core::fmt::Display;
2use core::fmt::Result;
3
4#[derive(Debug)]
5pub enum StmError {
6    /// The transaction encountered a conflict or invalid state and should be retried.
7    Retry,
8    /// A generic error string (for user logic).
9    User(String),
10}
11
12impl Display for StmError {
13    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result {
14        match self {
15            StmError::Retry => write!(f, "Transaction retry required"),
16            StmError::User(s) => write!(f, "Transaction error: {}", s),
17        }
18    }
19}
20
21impl std::error::Error for StmError {}