Skip to main content

cedar_policy_core/batched_evaluator/
err.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 contains possible errors thrown by batched evaluation
18
19use thiserror::Error;
20
21use crate::ast::PartialValueToValueError;
22use crate::tpe::err::{EntitiesError, MissingEntitiesError, PartialRequestError, TpeError};
23use crate::validator::RequestValidationError;
24
25/// Errors for Batched Evaluation
26#[derive(Debug, Error)]
27#[non_exhaustive]
28pub enum BatchedEvalError {
29    /// Error thrown by TPE
30    #[error(transparent)]
31    TPE(#[from] TpeError),
32    /// Error when the request is not valid
33    #[error(transparent)]
34    RequestValidation(#[from] RequestValidationError),
35    /// Error when the request is partial
36    #[error(transparent)]
37    PartialRequest(#[from] PartialRequestError),
38    /// Error when the loaded entities are not valid
39    #[error(transparent)]
40    Entities(#[from] EntitiesError),
41    /// Error thrown when a entity loader provided entity was partial instead of fully concrete
42    #[error(transparent)]
43    PartialValueToValue(#[from] PartialValueToValueError),
44    /// Error the entity loader failed to load all requested entities
45    #[error(transparent)]
46    MissingEntities(#[from] MissingEntitiesError),
47    /// Error when batched evaluation did not converge due to the iteration limit
48    #[error(transparent)]
49    InsufficientIterations(#[from] InsufficientIterationsError),
50}
51
52/// Batched evaluation may not return an answer when the maximum
53/// iterations is too low.
54#[derive(Debug, Error)]
55#[error("Batched evaluation failed: insufficient iteration limit.")]
56pub struct InsufficientIterationsError {}