use cedar_policy_core::validator::ValidationError;
use miette::Diagnostic;
use thiserror::Error;
pub use crate::symcc::{
ext::ExtError, extension_types::datetime::DatetimeError,
extension_types::decimal::DecimalError, extension_types::ipaddr::IPError, term::Term,
BitVecError, CompileError, ConcretizeError, DecodeError, EncodeError, SolverError,
};
#[derive(Debug, Diagnostic, Error)]
pub enum Error {
#[error("action not found in schema: {0}")]
ActionNotInSchema(String),
#[error("symbolic compilation failed: {0}")]
CompileError(#[from] CompileError),
#[error("failed to encode SMT terms: {0}")]
EncodeError(#[from] EncodeError),
#[error(transparent)]
SolverError(#[from] SolverError),
#[error("solver returned `unknown`")]
SolverUnknown,
#[error("input policy (set) is not well typed with respect to the schema")]
PolicyNotWellTyped {
#[related]
errs: Vec<ValidationError>,
},
#[error("failed to decode model: {0}")]
DecodeModel(#[from] DecodeError),
#[error("failed to recover a concrete counterexample: {0}")]
ConcretizeError(#[from] ConcretizeError),
#[error("model is invalid: violates assertion {assert}")]
ModelInvalid {
assert: Term,
},
#[error("expected to have at least one policy")]
NoPolicies,
}
pub type Result<T> = std::result::Result<T, Error>;