remora/crates/remora-admission/src/error.rs

30 lines
897 B
Rust
Raw Normal View History

2026-07-17 03:20:57 +09:00
use remora_credentials::CredentialError;
use remora_durable::DurableError;
use remora_identity::IdentityError;
#[derive(Debug, thiserror::Error)]
pub enum AdmissionError {
#[error("invalid submission: {0}")]
Invalid(String),
#[error("submission is not authorized")]
Unauthorized,
#[error("idempotency key was reused with a different request")]
IdempotencyConflict,
#[error("execution grant not found")]
GrantNotFound,
#[error("configuration error: {0}")]
Config(String),
#[error(transparent)]
Credential(#[from] CredentialError),
#[error(transparent)]
Durable(#[from] DurableError),
}
impl From<IdentityError> for AdmissionError {
fn from(error: IdentityError) -> Self {
match error {
IdentityError::UnauthorizedTarget => Self::Unauthorized,
other => Self::Invalid(other.to_string()),
}
}
}