ds_common_aws_rs_lib/ssm/
error.rs1use thiserror::Error;
6
7#[derive(Error, Debug)]
14pub enum SsmError {
15 #[error("request build failed")]
17 Build,
18
19 #[error("network/dispatch failed")]
21 Transport {
22 #[source]
23 source: Box<dyn std::error::Error + Send + Sync>,
24 request_id: Option<String>,
25 },
26
27 #[error("timeout")]
29 Timeout { request_id: Option<String> },
30
31 #[error("service error: {0}")]
33 Service(#[source] Box<dyn std::error::Error + Send + Sync>),
34
35 #[error("Invalid response: {0}")]
37 InvalidResponse(String),
38}
39
40pub fn map_ssm_err<E, R>(e: aws_smithy_runtime_api::client::result::SdkError<E, R>) -> SsmError
46where
47 E: std::error::Error + Send + Sync + 'static,
48{
49 use aws_smithy_runtime_api::client::result::SdkError::*;
50 match e {
51 ConstructionFailure(_cf) => SsmError::Build,
52 TimeoutError(_te) => SsmError::Timeout { request_id: None },
53 DispatchFailure(_df) => SsmError::Transport {
54 request_id: None,
55 source: Box::new(std::io::Error::other("Dispatch failure")),
56 },
57 ResponseError(_re) => SsmError::Service(Box::new(std::io::Error::other("Response error"))),
58 ServiceError(se) => SsmError::Service(Box::new(se.into_err())),
59 _ => SsmError::Service(Box::new(std::io::Error::other("Unknown error"))),
60 }
61}
62
63