Skip to main content

eduboardapi/exceptions/
mod.rs

1use std::error::Error;
2use std::fmt::{Display, Formatter, Result as FmtResult};
3
4#[derive(Debug)]
5pub enum AppError {
6    Network(String),
7    Parse(String),
8    Captcha(String),
9}
10
11impl Display for AppError {
12    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
13        match self {
14            AppError::Network(msg) => write!(f, "Network error: {}", msg),
15            AppError::Parse(msg) => write!(f, "Parse error: {}", msg),
16            AppError::Captcha(msg) => write!(f, "Captcha error: {}", msg),
17        }
18    }
19}
20
21impl Error for AppError {}
22
23pub type AppResult<T> = Result<T, AppError>;