rush_sync_server/core/
error.rs1use crate::core::prelude::*;
2use std::io;
3
4#[derive(Debug)]
5pub enum AppError {
6 Io(io::Error),
7 Validation(String),
8 Terminal(String),
9 Translation(TranslationError),
10}
11
12impl From<io::Error> for AppError {
13 fn from(err: io::Error) -> Self {
14 AppError::Terminal(err.to_string())
15 }
16}
17
18impl std::fmt::Display for AppError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 AppError::Io(err) => write!(f, "IO Error: {}", err),
22 AppError::Validation(msg) => write!(f, "Validation Error: {}", msg),
23 AppError::Terminal(msg) => write!(f, "Terminal Error: {}", msg),
24 AppError::Translation(err) => write!(f, "Translation Error: {}", err),
25 }
26 }
27}
28
29impl std::error::Error for AppError {}
30pub type Result<T> = std::result::Result<T, AppError>;