Struct aws_sdk_kms::error::EncryptError
source · #[non_exhaustive]pub struct EncryptError {
pub kind: EncryptErrorKind,
/* private fields */
}
Expand description
Error type for the Encrypt
operation.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.kind: EncryptErrorKind
Kind of error that occurred.
Implementations§
source§impl EncryptError
impl EncryptError
sourcepub fn new(kind: EncryptErrorKind, meta: Error) -> Self
pub fn new(kind: EncryptErrorKind, meta: Error) -> Self
Creates a new EncryptError
.
sourcepub fn unhandled(err: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
pub fn unhandled(err: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
Creates the EncryptError::Unhandled
variant from any error type.
Examples found in repository?
2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456
pub fn parse_encrypt_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::EncryptOutput, crate::error::EncryptError> {
let generic = crate::json_deser::parse_http_generic_error(response)
.map_err(crate::error::EncryptError::unhandled)?;
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::error::EncryptError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"DependencyTimeoutException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::DependencyTimeoutException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::dependency_timeout_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_dependency_timeout_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"DisabledException" => {
crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::DisabledException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::disabled_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_disabled_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
}
}
"InvalidGrantTokenException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::InvalidGrantTokenException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::invalid_grant_token_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_grant_token_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"InvalidKeyUsageException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::InvalidKeyUsageException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::invalid_key_usage_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_key_usage_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KeyUnavailableException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KeyUnavailableException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::key_unavailable_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_key_unavailable_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KMSInternalException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KmsInternalException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::kms_internal_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_kms_internal_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KMSInvalidStateException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KmsInvalidStateException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::kms_invalid_state_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_kms_invalid_state_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"NotFoundException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::NotFoundException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::not_found_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_not_found_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
_ => crate::error::EncryptError::generic(generic),
})
}
sourcepub fn generic(err: Error) -> Self
pub fn generic(err: Error) -> Self
Creates the EncryptError::Unhandled
variant from a aws_smithy_types::Error
.
Examples found in repository?
2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456
pub fn parse_encrypt_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::EncryptOutput, crate::error::EncryptError> {
let generic = crate::json_deser::parse_http_generic_error(response)
.map_err(crate::error::EncryptError::unhandled)?;
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::error::EncryptError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"DependencyTimeoutException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::DependencyTimeoutException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::dependency_timeout_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_dependency_timeout_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"DisabledException" => {
crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::DisabledException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::disabled_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_disabled_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
}
}
"InvalidGrantTokenException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::InvalidGrantTokenException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::invalid_grant_token_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_grant_token_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"InvalidKeyUsageException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::InvalidKeyUsageException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::invalid_key_usage_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_key_usage_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KeyUnavailableException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KeyUnavailableException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::key_unavailable_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_key_unavailable_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KMSInternalException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KmsInternalException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::kms_internal_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_kms_internal_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"KMSInvalidStateException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::KmsInvalidStateException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::kms_invalid_state_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_kms_invalid_state_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"NotFoundException" => crate::error::EncryptError {
meta: generic,
kind: crate::error::EncryptErrorKind::NotFoundException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::not_found_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_not_found_exception_json_err(response.body().as_ref(), output).map_err(crate::error::EncryptError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
_ => crate::error::EncryptError::generic(generic),
})
}
sourcepub fn meta(&self) -> &Error
pub fn meta(&self) -> &Error
Returns error metadata, which includes the error code, message, request ID, and potentially additional information.
sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the request ID if it’s available.
sourcepub fn is_dependency_timeout_exception(&self) -> bool
pub fn is_dependency_timeout_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::DependencyTimeoutException
.
sourcepub fn is_disabled_exception(&self) -> bool
pub fn is_disabled_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::DisabledException
.
sourcepub fn is_invalid_grant_token_exception(&self) -> bool
pub fn is_invalid_grant_token_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::InvalidGrantTokenException
.
sourcepub fn is_invalid_key_usage_exception(&self) -> bool
pub fn is_invalid_key_usage_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::InvalidKeyUsageException
.
Returns true
if the error kind is EncryptErrorKind::KeyUnavailableException
.
sourcepub fn is_kms_internal_exception(&self) -> bool
pub fn is_kms_internal_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::KmsInternalException
.
sourcepub fn is_kms_invalid_state_exception(&self) -> bool
pub fn is_kms_invalid_state_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::KmsInvalidStateException
.
sourcepub fn is_not_found_exception(&self) -> bool
pub fn is_not_found_exception(&self) -> bool
Returns true
if the error kind is EncryptErrorKind::NotFoundException
.