|
6 | 6 | //! Error metadata
|
7 | 7 |
|
8 | 8 | use crate::retry::{ErrorKind, ProvideErrorKind};
|
| 9 | +use std::borrow::Cow; |
9 | 10 | use std::collections::HashMap;
|
10 | 11 | use std::fmt;
|
11 | 12 |
|
@@ -39,11 +40,19 @@ pub const EMPTY_ERROR_METADATA: ErrorMetadata = ErrorMetadata {
|
39 | 40 | /// For many services, Errors are modeled. However, many services only partially model errors or don't
|
40 | 41 | /// model errors at all. In these cases, the SDK will return this generic error type to expose the
|
41 | 42 | /// `code`, `message` and `request_id`.
|
| 43 | +#[cfg_attr( |
| 44 | + all(aws_sdk_unstable, feature = "serde-serialize"), |
| 45 | + derive(serde::Serialize) |
| 46 | +)] |
| 47 | +#[cfg_attr( |
| 48 | + all(aws_sdk_unstable, feature = "serde-deserialize"), |
| 49 | + derive(serde::Deserialize) |
| 50 | +)] |
42 | 51 | #[derive(Debug, Eq, PartialEq, Default, Clone)]
|
43 | 52 | pub struct ErrorMetadata {
|
44 | 53 | code: Option<String>,
|
45 | 54 | message: Option<String>,
|
46 |
| - extras: Option<HashMap<&'static str, String>>, |
| 55 | + extras: Option<HashMap<Cow<'static, str>, String>>, |
47 | 56 | }
|
48 | 57 |
|
49 | 58 | /// Builder for [`ErrorMetadata`].
|
@@ -98,7 +107,7 @@ impl Builder {
|
98 | 107 | .extras
|
99 | 108 | .as_mut()
|
100 | 109 | .unwrap()
|
101 |
| - .insert(key, value.into()); |
| 110 | + .insert(Cow::Borrowed(key), value.into()); |
102 | 111 | self
|
103 | 112 | }
|
104 | 113 |
|
|
0 commit comments