cedar_policy_symcc/symcc/result.rs
1/*
2 * Copyright Cedar Contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! This module would more typically be called `err` or similar, but we call it
18//! `result` to match the Lean
19
20use cedar_policy::EntityTypeName;
21use miette::Diagnostic;
22use thiserror::Error;
23
24use super::bitvec::BitVecError;
25use super::ext::ExtError;
26use super::extension_types::ipaddr::IPError;
27
28/// Errors that can occur during symbolic compilation.
29/// Corresponds to `Cedar.SymCC.Result.Error` in the Lean version.
30#[derive(Debug, Diagnostic, Error)]
31pub enum CompileError {
32 /// Failed to find an entity type.
33 #[error("entity type {0} does not exist")]
34 NoSuchEntityType(EntityTypeName),
35 /// Failed to find an attribute.
36 #[error("attribute {0} does not exist")]
37 NoSuchAttribute(String),
38 /// Type error when constructing a [`super::term::Term`].
39 #[error("term type error")]
40 TypeError,
41 /// Unsupported features.
42 #[error("unsupported feature in SymCC: {0}")]
43 UnsupportedFeature(String),
44 /// Bit-vector error.
45 #[error("bit-vector error: {0}")]
46 BitVecError(#[from] BitVecError),
47 /// IP address error.
48 #[error("IP address error: {0}")]
49 IPError(#[from] IPError),
50 /// Context type is not a record.
51 #[error("context type is not a record")]
52 NonRecordContext,
53 /// Extension error.
54 #[error("extension error")]
55 ExtError(#[from] ExtError),
56}