1pub use aws_smithy_types::retry::ErrorKind;
10pub use aws_smithy_types::retry::ProvideErrorKind;
11pub use aws_smithy_types::retry::RetryConfig;
12pub use aws_smithy_types::retry::RetryConfigBuilder;
13pub use aws_smithy_types::retry::RetryKind;
14pub use aws_smithy_types::retry::RetryMode;
15
16pub mod error {
18 use std::fmt;
19 use std::num::ParseIntError;
20
21 pub use aws_smithy_types::retry::RetryModeParseError;
23
24 #[derive(Debug)]
25 pub(crate) enum RetryConfigErrorKind {
26 InvalidRetryMode {
28 source: RetryModeParseError,
30 },
31 MaxAttemptsMustNotBeZero,
33 FailedToParseMaxAttempts {
35 source: ParseIntError,
37 },
38 }
39
40 #[derive(Debug)]
42 pub struct RetryConfigError {
43 pub(crate) kind: RetryConfigErrorKind,
44 }
45
46 impl fmt::Display for RetryConfigError {
47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48 use RetryConfigErrorKind::*;
49 match &self.kind {
50 InvalidRetryMode { .. } => {
51 write!(f, "invalid retry configuration")
52 }
53 MaxAttemptsMustNotBeZero { .. } => {
54 write!(f, "invalid configuration: It is invalid to set max attempts to 0. Unset it or set it to an integer greater than or equal to one.")
55 }
56 FailedToParseMaxAttempts { .. } => {
57 write!(f, "failed to parse max attempts",)
58 }
59 }
60 }
61 }
62
63 impl std::error::Error for RetryConfigError {
64 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
65 use RetryConfigErrorKind::*;
66 match &self.kind {
67 InvalidRetryMode { source, .. } => Some(source),
68 FailedToParseMaxAttempts { source, .. } => Some(source),
69 MaxAttemptsMustNotBeZero { .. } => None,
70 }
71 }
72 }
73
74 impl From<RetryConfigErrorKind> for RetryConfigError {
75 fn from(kind: RetryConfigErrorKind) -> Self {
76 Self { kind }
77 }
78 }
79}