stable_bridge_package/
errors.rs1use mongodb::error::Error as MongoError;
2use reqwest::Error as ReqwestError;
3use serde_json::Error as SerdeError;
4use std::env::VarError;
5use std::io::Error as IoError;
6use std::num::ParseIntError;
7use thiserror::Error;
8
9#[derive(Debug, Error)]
10pub enum CustomError {
11 #[error("Custom error: {0}")]
12 Custom(String),
13
14 #[error("MongoDB error: {0}")]
15 Database(#[from] MongoError),
16
17 #[error("Environment variable error: {0}")]
18 EnvVar(#[from] VarError),
19
20 #[error("IO error: {0}")]
21 Io(#[from] IoError),
22
23 #[error("Reqwest error: {0}")]
24 Reqwest(#[from] ReqwestError),
25
26 #[error("Serde JSON error: {0}")]
27 Serde(#[from] SerdeError),
28
29 #[error("Parse Int error: {0}")]
30 ParseInt(#[from] ParseIntError),
31}
32
33impl CustomError {
34 pub fn new(msg: &str) -> Self {
36 CustomError::Custom(msg.to_string())
37 }
38}