Skip to main content

routee_compass/app/compass/
compass_app_error.rs

1use super::CompassComponentError;
2use crate::app::map_matching::MapMatchingAppError;
3use crate::plugin::{input::InputPluginError, output::OutputPluginError, PluginError};
4use config::ConfigError;
5use routee_compass_core::config::CompassConfigurationError;
6use routee_compass_core::{
7    algorithm::search::SearchError,
8    model::{
9        constraint::ConstraintModelError, cost::CostModelError, map::MapError,
10        network::NetworkError, state::StateModelError, termination::TerminationModelError,
11        traversal::TraversalModelError,
12    },
13};
14
15#[derive(thiserror::Error, Debug)]
16pub enum CompassAppError {
17    // TOP-LEVEL FAILURES
18    //   errors observed during build and run of compass that are not due to the search modules
19    #[error("failure building compass app: {0}")]
20    BuildFailure(String),
21    #[error("failure while running app: {0}")]
22    CompassFailure(String),
23    #[error("internal error: {0}")]
24    InternalError(String),
25    #[error("error accessing shared read-only dataset: {0}")]
26    ReadOnlyPoisonError(String),
27
28    // TRANSPARENT MODULE FAILURES
29    //   failures from these modules are detailed enough to get surfaced directly to the user
30    #[error(transparent)]
31    ConfigFailure(#[from] ConfigError),
32    #[error(transparent)]
33    CompassConfigurationError(#[from] CompassConfigurationError),
34    #[error(transparent)]
35    CompassComponentError(#[from] CompassComponentError),
36    #[error(transparent)]
37    SearchFailure(#[from] SearchError),
38    #[error(transparent)]
39    PluginError(#[from] PluginError),
40    #[error(transparent)]
41    InputPluginFailure(#[from] InputPluginError),
42    #[error(transparent)]
43    OutputPluginFailure(#[from] OutputPluginError),
44    #[error(transparent)]
45    MapMatchingFailure(#[from] MapMatchingAppError),
46
47    // CONTEXTUALIZED MODULE FAILURES
48    //   failures from these modules are happening outside of the context of running the search,
49    //   which is clarified for the user and may help direct where to look to solve the problem.
50    #[error("While interacting with the map model outside of the context of search, an error occurred. Source: {source}")]
51    MappingFailure {
52        #[from]
53        source: MapError,
54    },
55    #[error("While interacting with the state model outside of the context of search, an error occurred. Source: {source}")]
56    StateFailure {
57        #[from]
58        source: StateModelError,
59    },
60    #[error("While interacting with the network model outside of the context of search, an error occurred. Source: {source}")]
61    NetworkFailure {
62        #[from]
63        source: NetworkError,
64    },
65    #[error("While interacting with the termination model outside of the context of search, an error occurred. Source: {source}")]
66    TerminationModelFailure {
67        #[from]
68        source: TerminationModelError,
69    },
70    #[error("While interacting with the traversal model outside of the context of search, an error occurred. Source: {source}")]
71    TraversalModelFailure {
72        #[from]
73        source: TraversalModelError,
74    },
75    #[error("While interacting with the constraint model outside of the context of search, an error occurred. Source: {source}")]
76    ConstraintModelFailure {
77        #[from]
78        source: ConstraintModelError,
79    },
80    #[error("While interacting with the cost model outside of the context of search, an error occurred. Source: {source}")]
81    CostFailure {
82        #[from]
83        source: CostModelError,
84    },
85    #[error("failure due to JSON: {source}")]
86    JsonError {
87        #[from]
88        source: serde_json::Error,
89    },
90}