1use std::io;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum AppError {
7 #[error("{0}")]
8 Message(String),
9 #[error("I/O error: {0}")]
10 Io(#[from] io::Error),
11 #[error("JSON error: {0}")]
12 Json(#[from] serde_json::Error),
13 #[error("Network error: {0}")]
14 Network(String),
15 #[error("MSF-RPC error: {0}")]
16 Rpc(String),
17 #[error("MSF-RPC module not found: {0}")]
18 RpcModuleNotFound(String),
19 #[error("msgpack error: {0}")]
20 Msgpack(String),
21 #[error("invalid data: {0}")]
22 InvalidData(String),
23 #[error("SQLite error: {0}")]
24 Sqlite(String),
25}
26
27impl From<rusqlite::Error> for AppError {
28 fn from(err: rusqlite::Error) -> Self {
29 AppError::Sqlite(err.to_string())
30 }
31}
32
33pub type Result<T> = std::result::Result<T, AppError>;