use crate::ast::*;
use crate::evaluator::EvaluationError;
use miette::Diagnostic;
use smol_str::SmolStr;
use thiserror::Error;
#[derive(Debug, PartialEq, Eq, Clone, Diagnostic, Error)]
pub enum AuthorizationError {
#[error("while evaluating policy `{id}`: {error}")]
#[diagnostic(forward(error))]
PolicyEvaluationError {
id: PolicyID,
error: EvaluationError,
},
}
#[derive(Debug, Error, Diagnostic)]
pub enum ConcretizationError {
#[error("invalid value {given_value} of {id}: expected type {expected_type}")]
ValueError {
id: SmolStr,
expected_type: &'static str,
given_value: Value,
},
#[error("concretizing existing value {existing_value} of {id} with value {given_value}")]
VarConfictError {
id: SmolStr,
existing_value: PartialValue,
given_value: Value,
},
#[error("concretizing existing but unknown entity value of type {existing_value} of {id} with value {given_value}")]
EntityTypeConfictError {
id: SmolStr,
existing_value: EntityType,
given_value: Value,
},
#[error(transparent)]
#[diagnostic(transparent)]
ValueEval(#[from] EvaluationError),
}
#[derive(Debug, Error, Diagnostic)]
pub enum ReauthorizationError {
#[error(transparent)]
#[diagnostic(transparent)]
PolicySetError(#[from] PolicySetError),
#[error(transparent)]
#[diagnostic(transparent)]
ConcretizationError(#[from] ConcretizationError),
}