scuffle_cedar_policy_codegen/
error.rs1use cedar_policy_core::ast::Id;
2use cedar_policy_core::validator::{CedarSchemaError, SchemaError};
3
4#[derive(thiserror::Error, Debug)]
6pub enum CodegenError {
7 #[error("multiple types with name {0}")]
9 DuplicateType(Id),
10 #[error("unsupported: {0}")]
12 Unsupported(String),
13 #[error("multiple actions with name {0}")]
15 DuplicateAction(String),
16 #[error("unresolved reference: {0}")]
18 UnresolvedReference(String),
19 #[error("expected entity not common type of {common_type} when declaring {ty}")]
21 ExpectedEntity {
22 common_type: String,
24 ty: String,
26 },
27 #[error(transparent)]
29 CedarSchemaError(#[from] Box<CedarSchemaError>),
30 #[error(transparent)]
32 SchemaError(#[from] Box<SchemaError>),
33}
34
35impl From<SchemaError> for CodegenError {
36 fn from(value: SchemaError) -> Self {
37 Self::SchemaError(Box::new(value))
38 }
39}
40
41impl From<CedarSchemaError> for CodegenError {
42 fn from(value: CedarSchemaError) -> Self {
43 Self::CedarSchemaError(Box::new(value))
44 }
45}
46
47pub type CodegenResult<T, E = CodegenError> = std::result::Result<T, E>;