pub enum AmiError {
Provider {
provider: String,
message: String,
},
Serialization(Error),
InvalidParameter {
message: String,
},
OperationNotSupported {
operation: String,
},
ResourceNotFound {
resource: String,
},
PermissionDenied {
reason: String,
},
AccessDenied {
message: String,
},
ResourceLimitExceeded {
resource_type: String,
limit: usize,
},
ResourceExists {
resource: String,
},
StoreError(String),
UnreadablePolicy {
policy: String,
message: String,
},
}Variants§
Provider
A provider rejected an operation.
Replaces the AwsSdk, StsSdk and SsoAdminSdk variants removed in 0.14. Those named SDK error types in their signature, so every consumer compiled three AWS SDKs to hold three variants this workspace never constructed once. Carrying the provider name and its message keeps the information without keeping the dependency:
client.get_user().send().await.map_err(|e| AmiError::Provider {
provider: "aws".to_string(),
message: e.to_string(),
})?Serialization(Error)
InvalidParameter
OperationNotSupported
ResourceNotFound
PermissionDenied
AccessDenied
ResourceLimitExceeded
ResourceExists
StoreError(String)
UnreadablePolicy
A policy document could not be parsed, so no decision can be made from it.
Deliberately an error and not a denial. A denial means “the rules
forbid this”; an unreadable policy means “the rules cannot be read” —
and the caller must be able to tell those apart, because the first is a
403 the user can act on and the second is a corrupt store that should
page someone. Folding it into AccessDenied would hide a broken policy
store behind what looks like an ordinary permission failure.
Implementations§
Source§impl AmiError
Helper functions for creating common AmiError variants
impl AmiError
Helper functions for creating common AmiError variants
Sourcepub fn resource_not_found(resource_type: &str, resource_id: &str) -> Self
pub fn resource_not_found(resource_type: &str, resource_id: &str) -> Self
Create a “Resource not found” error with a formatted message
§Example
use wami_core::error::AmiError;
let error = AmiError::resource_not_found("User", "alice");
assert!(error.to_string().contains("User: alice"));Sourcepub fn permission_denied(action: &str, resource: &str) -> Self
pub fn permission_denied(action: &str, resource: &str) -> Self
Create a “Permission denied” error with action and resource context
§Example
use wami_core::error::AmiError;
let error = AmiError::permission_denied("delete", "User: alice");
assert!(error.to_string().contains("Cannot delete"));Sourcepub fn access_denied(message: impl Into<String>) -> Self
pub fn access_denied(message: impl Into<String>) -> Self
Create an “Access denied” error with a detailed message
§Example
use wami_core::error::AmiError;
let error = AmiError::access_denied("User alice does not have permission to delete users");Sourcepub fn invalid_parameter(message: impl Into<String>) -> Self
pub fn invalid_parameter(message: impl Into<String>) -> Self
Create an “Invalid parameter” error
§Example
use wami_core::error::AmiError;
let error = AmiError::invalid_parameter("User name cannot be empty");Sourcepub fn resource_exists(resource: impl Into<String>) -> Self
pub fn resource_exists(resource: impl Into<String>) -> Self
Create a “Resource already exists” error
§Example
use wami_core::error::AmiError;
let error = AmiError::resource_exists("User: alice");Sourcepub fn resource_limit_exceeded(resource_type: &str, limit: usize) -> Self
pub fn resource_limit_exceeded(resource_type: &str, limit: usize) -> Self
Create a “Resource limit exceeded” error
§Example
use wami_core::error::AmiError;
let error = AmiError::resource_limit_exceeded("AccessKey", 2);Sourcepub fn operation_not_supported(operation: impl Into<String>) -> Self
pub fn operation_not_supported(operation: impl Into<String>) -> Self
Create an “Operation not supported” error
§Example
use wami_core::error::AmiError;
let error = AmiError::operation_not_supported("batch_delete");Trait Implementations§
Source§impl Error for AmiError
impl Error for AmiError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()