elif_http/bootstrap/
app_module.rs1use crate::{bootstrap::AppBootstrapper, HttpError};
4
5pub trait AppBootstrap {
10 fn bootstrap() -> BootstrapResult<AppBootstrapper>;
19}
20
21#[derive(Debug, thiserror::Error)]
23pub enum BootstrapError {
24 #[error("Module discovery failed: {message}")]
25 ModuleDiscoveryFailed { message: String },
26
27 #[error("Circular dependency detected: {cycle:?}")]
28 CircularDependency { cycle: Vec<String> },
29
30 #[error("Missing dependency: module '{module}' depends on '{dependency}' which is not registered")]
31 MissingDependency { module: String, dependency: String },
32
33 #[error("Module registration failed: {message}")]
34 ModuleRegistrationFailed { message: String },
35
36 #[error("Container configuration failed: {message}")]
37 ContainerConfigurationFailed { message: String },
38
39 #[error("Route registration failed: {message}")]
40 RouteRegistrationFailed { message: String },
41
42 #[error("Controller not found: '{controller_name}'. Available controllers: {available_controllers:?}")]
43 ControllerNotFound { controller_name: String, available_controllers: Vec<String> },
44
45 #[error("Controller registration failed: {message}")]
46 ControllerRegistrationFailed { message: String },
47
48 #[error("Controller metadata extraction failed: {message}")]
49 ControllerMetadataFailed { message: String },
50
51 #[error("Server startup failed: {message}")]
52 ServerStartupFailed { message: String },
53
54 #[error("HTTP error during bootstrap: {0}")]
55 HttpError(#[from] HttpError),
56}
57
58impl From<BootstrapError> for HttpError {
59 fn from(error: BootstrapError) -> Self {
60 match error {
61 BootstrapError::HttpError(http_error) => http_error,
62 _ => HttpError::InternalError { message: format!("Bootstrap failed: {}", error) },
63 }
64 }
65}
66
67pub type BootstrapResult<T> = Result<T, BootstrapError>;