use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("exchange error: {0}")]
Exchange(String),
#[error("brain error: {0}")]
Brain(String),
#[error("risk check blocked: {0}")]
Risk(String),
#[error("configuration error: {0}")]
Config(String),
#[error("serde error: {0}")]
Serde(#[from] serde_json::Error),
#[error("state store error: {0}")]
Storage(String),
#[error("internal error: {0}")]
Internal(String),
}
impl Error {
pub fn exchange(msg: impl Into<String>) -> Self {
Self::Exchange(msg.into())
}
pub fn brain(msg: impl Into<String>) -> Self {
Self::Brain(msg.into())
}
pub fn risk(msg: impl Into<String>) -> Self {
Self::Risk(msg.into())
}
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
pub fn internal(msg: impl Into<String>) -> Self {
Self::Internal(msg.into())
}
pub fn storage(msg: impl Into<String>) -> Self {
Self::Storage(msg.into())
}
}