-
I have code that calls I've tried to write this, but as far as I can tell the This seems like it would be a common usecase, but maybe I'm approaching it incorrectly? The end goal is an |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
So essentially, you can do something like this: match call_kms_encrypt().await {
Ok(success) => { /* do success stuff */ },
Err(err) => aws_sdk_kms::Error::from(err.into_service_error())?,
} Where your Edit: Actually, it's even simpler than that. match call_kms_encrypt().await {
Ok(success) => { /* do success stuff */ },
Err(err) => aws_sdk_kms::Error::from(err)?,
} |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
-
@jdisanti Has there been any more thought put into this? I would also like to be able to easily/ergonomically propagate the contextual information such as Timeouts and Auth errors. |
Beta Was this translation helpful? Give feedback.
SdkError
has aninto_service_error()
function that will convert it into the error type for the operation you called (for example,EncryptError
for theEncrypt
operation). Then theError
type at the crate root implementsFrom
for every one of these service error types.So essentially, you can do something like this:
Where your
ApplicationError
implementsFrom<aws_sdk_kms::Error>
. At that point, you're only dealing with conversion of one error type.Edit: Actually, it's even simpler than that.
aws_sdk_kms::Error
already implementsFrom<SdkError>