pub struct Builder { /* private fields */ }
Expand description
Builder for ErrorMetadata
.
Implementations§
source§impl Builder
impl Builder
sourcepub fn custom(self, key: &'static str, value: impl Into<String>) -> Self
pub fn custom(self, key: &'static str, value: impl Into<String>) -> Self
Set a custom field on the error metadata
Typically, these will be accessed with an extension trait:
use aws_smithy_types::error::ErrorMetadata;
const HOST_ID: &str = "host_id";
trait S3ErrorExt {
fn extended_request_id(&self) -> Option<&str>;
}
impl S3ErrorExt for ErrorMetadata {
fn extended_request_id(&self) -> Option<&str> {
self.extra(HOST_ID)
}
}
fn main() {
// Extension trait must be brought into scope
use S3ErrorExt;
let sdk_response: Result<(), ErrorMetadata> = Err(ErrorMetadata::builder().custom(HOST_ID, "x-1234").build());
if let Err(err) = sdk_response {
println!("extended request id: {:?}", err.extended_request_id());
}
}
sourcepub fn build(self) -> ErrorMetadata
pub fn build(self) -> ErrorMetadata
Creates the error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more