routee_compass/app/compass/
compass_app_error.rs

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