1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Error, Debug)]
10pub enum Error {
11 #[error("Service not found: {0}")]
13 ServiceNotFound(String),
14
15 #[error("Service registration failed: {0}")]
17 RegistrationError(String),
18
19 #[error("HTTP server error: {0}")]
21 ServerError(String),
22
23 #[error("Route registration failed: {0}")]
25 RouteError(String),
26
27 #[error("Error: {0}")]
29 Other(String),
30}
31
32impl Error {
33 pub fn service_not_found(service_name: impl Into<String>) -> Self {
35 Self::ServiceNotFound(service_name.into())
36 }
37
38 pub fn registration_error(msg: impl Into<String>) -> Self {
40 Self::RegistrationError(msg.into())
41 }
42
43 pub fn server_error(msg: impl Into<String>) -> Self {
45 Self::ServerError(msg.into())
46 }
47
48 pub fn route_error(msg: impl Into<String>) -> Self {
50 Self::RouteError(msg.into())
51 }
52
53 pub fn other(msg: impl Into<String>) -> Self {
55 Self::Other(msg.into())
56 }
57}