Files
crank/crates/crank-runtime/src/error.rs
T

81 lines
3.5 KiB
Rust

use crank_core::{ExecutionMode, OperationSafetyClass, Protocol, ProtocolAdapterError};
use crank_mapping::MappingError;
use crank_schema::SchemaError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RuntimeError {
#[error("execution request is invalid")]
InvalidExecutionRequest,
#[error("execution deadline elapsed")]
ExecutionDeadlineElapsed { may_have_dispatched: bool },
#[error(transparent)]
Schema(#[from] SchemaError),
#[error(transparent)]
InputSchema(SchemaError),
#[error(transparent)]
OutputSchema(SchemaError),
#[error(transparent)]
Mapping(#[from] MappingError),
#[error(transparent)]
InputMapping(MappingError),
#[error(transparent)]
OutputMapping(MappingError),
#[error(transparent)]
ProtocolAdapter(#[from] ProtocolAdapterError),
#[error("protocol {protocol:?} is not supported by runtime")]
UnsupportedProtocol { protocol: Protocol },
#[error("operation {operation_id} does not support requested execution mode {mode:?}")]
UnsupportedExecutionMode {
operation_id: String,
mode: ExecutionMode,
},
#[error("runtime concurrency limit exceeded for {kind} executions (limit {limit})")]
ConcurrencyLimitExceeded { kind: &'static str, limit: usize },
#[error("invalid prepared request at {field}: {reason}")]
InvalidPreparedRequest { field: String, reason: String },
#[error(
"operation {operation_id} requires confirmation for {safety_class:?} action; retry with confirmation token {confirmation_token}"
)]
ConfirmationRequired {
operation_id: String,
safety_class: OperationSafetyClass,
confirmation_token: String,
expires_in_ms: u64,
},
#[error("confirmation token for operation {operation_id} is invalid, expired, or already used")]
InvalidConfirmationToken { operation_id: String },
#[error("confirmation store is unavailable for operation {operation_id}")]
ConfirmationStoreUnavailable { operation_id: String },
#[error("idempotency store is unavailable for operation {operation_id}")]
IdempotencyStoreUnavailable { operation_id: String },
#[error("operation {operation_id} is already executing for this idempotency key")]
IdempotencyInProgress { operation_id: String },
#[error("idempotency key for operation {operation_id} was reused with different input")]
IdempotencyConflict { operation_id: String },
#[error("the outcome of operation {operation_id} is unknown; automatic retry is unsafe")]
IdempotencyOutcomeUnknown { operation_id: String },
#[error("idempotency completion is unavailable after operation {operation_id} dispatch")]
IdempotencyCompletionUnknown { operation_id: String },
#[error("authorization storage is unavailable")]
AuthorizationStoreUnavailable,
#[error("auth profile {auth_profile_id} was not found")]
MissingAuthProfile { auth_profile_id: String },
#[error("auth profile {auth_profile_id} is invalid: {reason}")]
InvalidAuthProfileConfig {
auth_profile_id: String,
reason: String,
},
#[error("secret {secret_id} was not found")]
MissingSecret { secret_id: String },
#[error("secret {secret_id} does not have current version {version}")]
MissingSecretVersion { secret_id: String, version: u32 },
#[error("invalid secret payload for {secret_id}: {reason}")]
InvalidAuthSecretValue { secret_id: String, reason: String },
#[error("secret crypto error during {operation}: {details}")]
SecretCrypto {
operation: &'static str,
details: String,
},
}