use arcbox_error::CommonError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, ApiError>;
#[derive(Debug, Error)]
pub enum ApiError {
#[error(transparent)]
Common(#[from] CommonError),
#[error("core error: {0}")]
Core(#[from] arcbox_core::CoreError),
#[error("gRPC error: {0}")]
Grpc(#[from] tonic::transport::Error),
#[error("server error: {0}")]
Server(String),
#[error("transport error: {0}")]
Transport(String),
}
impl From<std::io::Error> for ApiError {
fn from(err: std::io::Error) -> Self {
Self::Common(CommonError::from(err))
}
}
impl ApiError {
#[must_use]
pub fn config(msg: impl Into<String>) -> Self {
Self::Common(CommonError::config(msg))
}
}