1use core::fmt::Display;
4
5pub type HandlerResponse<T> = Result<T, ServiceError>;
7
8#[derive(Debug)]
15pub enum ServiceError {
16 Authentication,
17 Authorization,
18 Internal(Box<dyn std::error::Error + Send + Sync>),
19}
20
21impl Display for ServiceError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 ServiceError::Authentication => write!(f, "authentication error"),
25 ServiceError::Authorization => write!(f, "not authorized"),
26 ServiceError::Internal(e) => write!(f, "internal server error: {:?}", e),
27 }
28 }
29}