securitydept_token_set_context/access_token_substrate/forwarder/
error.rs1use securitydept_utils::error::{ErrorPresentation, ToErrorPresentation, UserRecovery};
2use snafu::Snafu;
3
4use super::super::TokenPropagatorError;
5
6#[derive(Debug, Snafu)]
11pub enum PropagationForwarderError {
12 #[snafu(display("propagation forwarder is misconfigured: {message}"))]
13 Config { message: String },
14 #[snafu(display("token propagation failed: {source}"), context(false))]
15 TokenPropagator { source: TokenPropagatorError },
16 #[snafu(display("resolved propagation target origin is invalid: {source}"))]
17 InvalidOrigin { source: url::ParseError },
18}
19
20pub type PropagationForwarderResult<T> = Result<T, PropagationForwarderError>;
21
22impl ToErrorPresentation for PropagationForwarderError {
23 fn to_error_presentation(&self) -> ErrorPresentation {
24 match self {
25 Self::Config { .. } => ErrorPresentation::new(
26 "propagation_forwarder_config_invalid",
27 "The propagation forwarder is misconfigured.",
28 UserRecovery::ContactSupport,
29 ),
30 Self::TokenPropagator { source } => source.to_error_presentation(),
31 Self::InvalidOrigin { .. } => ErrorPresentation::new(
32 "propagation_forwarder_invalid_origin",
33 "The propagation target URL is invalid.",
34 UserRecovery::ContactSupport,
35 ),
36 }
37 }
38}