radixdb_core/error/
context.rs1use super::{ErrorCategory, ErrorCode};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub struct ErrorContext {
6 code: ErrorCode,
7 category: ErrorCategory,
8 retryable: bool,
9 not_found: bool,
10 constraint_violation: bool,
11}
12
13impl ErrorContext {
14 pub(super) const fn new(
15 code: ErrorCode,
16 category: ErrorCategory,
17 retryable: bool,
18 not_found: bool,
19 constraint_violation: bool,
20 ) -> Self {
21 Self {
22 code,
23 category,
24 retryable,
25 not_found,
26 constraint_violation,
27 }
28 }
29
30 pub const fn code(self) -> ErrorCode {
31 self.code
32 }
33
34 pub const fn category(self) -> ErrorCategory {
35 self.category
36 }
37
38 pub const fn retryable(self) -> bool {
39 self.retryable
40 }
41
42 pub const fn not_found(self) -> bool {
43 self.not_found
44 }
45
46 pub const fn constraint_violation(self) -> bool {
47 self.constraint_violation
48 }
49}