gatekeep_keepsake/error.rs
1use gatekeep::{FactId, GatekeepError, SubjectSlot};
2use keepsake::KeepsakeError;
3use thiserror::Error;
4
5/// Backend error emitted by [`crate::KeepsakeResolver`].
6#[derive(Debug, Error)]
7pub enum KeepsakeResolveError<E> {
8 /// Gatekeep and keepsake subject validation drifted apart.
9 #[error(transparent)]
10 Subject(#[from] KeepsakeError),
11 /// The active-relation source failed.
12 #[error("keepsake relation source failed")]
13 Source(#[source] E),
14 /// Gatekeep refused a constructed known-fact bundle.
15 #[error(transparent)]
16 Gatekeep(#[from] GatekeepError),
17}
18
19/// Errors returned while resolving a gatekeep fact into a keepsake target.
20#[derive(Debug, Error, Clone, PartialEq, Eq)]
21pub enum KeepsakeTargetError {
22 /// The resolver has no binding for the requested fact.
23 #[error("no keepsake binding configured for fact {fact}")]
24 MissingBinding {
25 /// Unbound fact id.
26 fact: FactId,
27 },
28
29 /// The binding targets a request-scoped subject slot missing from the context.
30 #[error("context is missing subject slot {slot} for fact {fact}")]
31 MissingSubjectSlot {
32 /// Fact whose binding needs the subject.
33 fact: FactId,
34 /// Missing subject slot.
35 slot: SubjectSlot,
36 },
37
38 /// Gatekeep and keepsake subject validation drifted apart.
39 #[error("keepsake subject validation failed for fact {fact}")]
40 Subject {
41 /// Fact whose target subject could not be built.
42 fact: FactId,
43 /// Validation failure from keepsake.
44 #[source]
45 source: KeepsakeError,
46 },
47
48 /// Gatekeep's validated tenant could not be represented as a keepsake
49 /// tenant identity.
50 #[error("keepsake tenant validation failed for fact {fact}")]
51 Tenant {
52 /// Fact whose tenant conversion failed.
53 fact: FactId,
54 /// Validation failure from keepsake.
55 #[source]
56 source: KeepsakeError,
57 },
58}