pub struct Builder { /* private fields */ }
Expand description

Builder for Error.

Implementations§

Sets the error message.

Sets the error code.

Sets the request ID the error happened for.

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());
    }
}

Creates the error.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.