graphrecords_query/traits/
errors.rs1use crate::{
2 Diagnostic, ErrorGroup, Operand,
3 operations::{
4 Apply, BucketErrorPolicy, BucketErrorPolicyIn, BucketErrorPolicyOf,
5 BucketErrorPolicyWithCause, ErrorPolicy, ErrorPolicyIn, ErrorPolicyOf,
6 ErrorPolicyWithCause, HasErrorCauseOperation, InErrorGroupOperation, IsErrorKindOperation,
7 KeyErrorPolicy, KeyErrorPolicyIn, KeyErrorPolicyOf, KeyErrorPolicyWithCause,
8 },
9};
10use std::error::Error;
11
12pub trait Errors {
13 type ReturnOperand;
14
15 fn errors(&self) -> Self::ReturnOperand;
16}
17
18pub trait ErrorKind {
19 type ReturnOperand;
20
21 fn kind(&self) -> Self::ReturnOperand;
22}
23
24pub trait IsErrorKind {
25 type ReturnOperand<D>
26 where
27 D: Diagnostic,
28 Self: Apply<IsErrorKindOperation<D>>;
29
30 fn is<D>(&self) -> Self::ReturnOperand<D>
31 where
32 D: Diagnostic,
33 Self: Apply<IsErrorKindOperation<D>>;
34}
35
36pub trait InErrorGroup {
37 type ReturnOperand<G>
38 where
39 G: ErrorGroup,
40 Self: Apply<InErrorGroupOperation<G>>;
41
42 fn in_error_group<G>(&self) -> Self::ReturnOperand<G>
43 where
44 G: ErrorGroup,
45 Self: Apply<InErrorGroupOperation<G>>;
46}
47
48pub trait HasErrorCause {
49 type ReturnOperand<C>
50 where
51 C: Error + 'static,
52 Self: Apply<HasErrorCauseOperation<C>>;
53
54 fn has_cause<C>(&self) -> Self::ReturnOperand<C>
55 where
56 C: Error + 'static,
57 Self: Apply<HasErrorCauseOperation<C>>;
58}
59
60pub trait ErrorKindName {
61 type ReturnOperand;
62
63 fn name(&self) -> Self::ReturnOperand;
64}
65
66pub trait OnError: Operand {
67 fn on_error<A: ErrorPolicy<Self>>(&self, policy: A) -> A::Output;
68}
69
70pub trait OnErrorOf<A>: Operand {
71 type ReturnOperand<D>
72 where
73 D: Diagnostic,
74 A: ErrorPolicyOf<Self, D>;
75
76 fn on_error_of<D>(&self, policy: A) -> Self::ReturnOperand<D>
77 where
78 D: Diagnostic,
79 A: ErrorPolicyOf<Self, D>;
80}
81
82pub trait OnErrorIn<A>: Operand {
83 type ReturnOperand<G>
84 where
85 G: ErrorGroup,
86 A: ErrorPolicyIn<Self, G>;
87
88 fn on_error_in<G>(&self, policy: A) -> Self::ReturnOperand<G>
89 where
90 G: ErrorGroup,
91 A: ErrorPolicyIn<Self, G>;
92}
93
94pub trait OnErrorWithCause<A>: Operand {
95 type ReturnOperand<C>
96 where
97 C: Error + 'static,
98 A: ErrorPolicyWithCause<Self, C>;
99
100 fn on_error_with_cause<C>(&self, policy: A) -> Self::ReturnOperand<C>
101 where
102 C: Error + 'static,
103 A: ErrorPolicyWithCause<Self, C>;
104}
105
106pub trait BucketErrors {
107 type ReturnOperand;
108
109 fn bucket_errors(&self) -> Self::ReturnOperand;
110}
111
112pub trait KeyErrors {
113 type ReturnOperand;
114
115 fn key_errors(&self) -> Self::ReturnOperand;
116}
117
118pub trait OnBucketError: Operand {
119 fn on_bucket_error<A: BucketErrorPolicy<Self>>(&self, policy: A) -> A::Output;
120}
121
122pub trait OnBucketErrorOf<A>: Operand {
123 type ReturnOperand<D>
124 where
125 D: Diagnostic,
126 A: BucketErrorPolicyOf<Self, D>;
127
128 fn on_bucket_error_of<D>(&self, policy: A) -> Self::ReturnOperand<D>
129 where
130 D: Diagnostic,
131 A: BucketErrorPolicyOf<Self, D>;
132}
133
134pub trait OnBucketErrorIn<A>: Operand {
135 type ReturnOperand<G>
136 where
137 G: ErrorGroup,
138 A: BucketErrorPolicyIn<Self, G>;
139
140 fn on_bucket_error_in<G>(&self, policy: A) -> Self::ReturnOperand<G>
141 where
142 G: ErrorGroup,
143 A: BucketErrorPolicyIn<Self, G>;
144}
145
146pub trait OnBucketErrorWithCause<A>: Operand {
147 type ReturnOperand<C>
148 where
149 C: Error + 'static,
150 A: BucketErrorPolicyWithCause<Self, C>;
151
152 fn on_bucket_error_with_cause<C>(&self, policy: A) -> Self::ReturnOperand<C>
153 where
154 C: Error + 'static,
155 A: BucketErrorPolicyWithCause<Self, C>;
156}
157
158pub trait OnKeyError: Operand {
159 fn on_key_error<A: KeyErrorPolicy<Self>>(&self, policy: A) -> A::Output;
160}
161
162pub trait OnKeyErrorOf<A>: Operand {
163 type ReturnOperand<D>
164 where
165 D: Diagnostic,
166 A: KeyErrorPolicyOf<Self, D>;
167
168 fn on_key_error_of<D>(&self, policy: A) -> Self::ReturnOperand<D>
169 where
170 D: Diagnostic,
171 A: KeyErrorPolicyOf<Self, D>;
172}
173
174pub trait OnKeyErrorIn<A>: Operand {
175 type ReturnOperand<G>
176 where
177 G: ErrorGroup,
178 A: KeyErrorPolicyIn<Self, G>;
179
180 fn on_key_error_in<G>(&self, policy: A) -> Self::ReturnOperand<G>
181 where
182 G: ErrorGroup,
183 A: KeyErrorPolicyIn<Self, G>;
184}
185
186pub trait OnKeyErrorWithCause<A>: Operand {
187 type ReturnOperand<C>
188 where
189 C: Error + 'static,
190 A: KeyErrorPolicyWithCause<Self, C>;
191
192 fn on_key_error_with_cause<C>(&self, policy: A) -> Self::ReturnOperand<C>
193 where
194 C: Error + 'static,
195 A: KeyErrorPolicyWithCause<Self, C>;
196}