octopus_engine/
errors.rs

1use std::{error::Error, fmt};
2
3use serde::{Deserialize, Serialize};
4
5/// An application-specific error type
6#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
7pub enum AccountError {
8    // Add variants here for account not found, account underfunded and account overfunded
9    NotFound(String),
10    OverFunded(String, u64),
11    UnderFunded(String),
12}
13
14#[derive(Debug, Serialize, Deserialize)]
15pub struct OctopusError(pub AccountError);
16
17impl fmt::Display for OctopusError {
18    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19        write!(f, "There is an error: {:?}", self.0)
20    }
21}
22
23impl Error for OctopusError {}