cedar_policy/api/err/
validation_errors.rs1use miette::Diagnostic;
18use ref_cast::RefCast;
19use thiserror::Error;
20
21use crate::PolicyId;
22
23#[cfg(doc)]
27use crate::ValidationError;
28
29macro_rules! wrap_core_error {
36 ($s:ident) => {
37 #[derive(Debug, Clone, Error, Diagnostic)]
38 #[error(transparent)]
39 #[diagnostic(transparent)]
40 #[doc=concat!("Structure containing details about a [`ValidationError::", stringify!($s), "`].")]
41 pub struct $s(cedar_policy_validator::validation_errors::$s);
42
43 impl $s {
44 pub fn policy_id(&self) -> &PolicyId {
46 PolicyId::ref_cast(&self.0.policy_id)
47 }
48 }
49
50 #[doc(hidden)]
51 impl From<cedar_policy_validator::validation_errors::$s> for $s {
52 fn from(e: cedar_policy_validator::validation_errors::$s) -> Self {
53 Self(e)
54 }
55 }
56 };
57}
58
59wrap_core_error!(UnrecognizedEntityType);
60wrap_core_error!(UnrecognizedActionId);
61wrap_core_error!(InvalidActionApplication);
62wrap_core_error!(UnexpectedType);
63wrap_core_error!(IncompatibleTypes);
64wrap_core_error!(UnsafeAttributeAccess);
65wrap_core_error!(UnsafeOptionalAttributeAccess);
66wrap_core_error!(UnsafeTagAccess);
67wrap_core_error!(NoTagsAllowed);
68wrap_core_error!(UndefinedFunction);
69wrap_core_error!(WrongNumberArguments);
70wrap_core_error!(FunctionArgumentValidation);
71wrap_core_error!(HierarchyNotRespected);
72wrap_core_error!(EntityDerefLevelViolation);
73wrap_core_error!(EmptySetForbidden);
74wrap_core_error!(NonLitExtConstructor);
75wrap_core_error!(InternalInvariantViolation);