Struct aws_smithy_types::error::Builder
source · [−]pub struct Builder { /* private fields */ }
Expand description
Builder for Error
.
Implementations
sourceimpl Builder
impl Builder
sourcepub fn request_id(&mut self, request_id: impl Into<String>) -> &mut Self
pub fn request_id(&mut self, request_id: impl Into<String>) -> &mut Self
Sets the request ID the error happened for.
sourcepub fn custom(
&mut self,
key: &'static str,
value: impl Into<String>
) -> &mut Self
pub fn custom(
&mut self,
key: &'static str,
value: impl Into<String>
) -> &mut Self
Set a custom field on the error metadata
Typically, these will be accessed with an extension trait:
use aws_smithy_types::Error;
const HOST_ID: &str = "host_id";
trait S3ErrorExt {
fn extended_request_id(&self) -> Option<&str>;
}
impl S3ErrorExt for Error {
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<(), Error> = Err(Error::builder().custom(HOST_ID, "x-1234").build());
if let Err(err) = sdk_response {
println!("request id: {:?}, extended request id: {:?}", err.request_id(), err.extended_request_id());
}
}
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more