Skip to main content

harmos_domain/
error.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19
20// Local Imports
21
22/* === Constants === */
23
24/* === Macros === */
25
26/* === Type Aliases === */
27
28pub type Result<T> = std::result::Result<T, Error>;
29
30/* === Structs === */
31
32/* === Enums === */
33
34#[derive(Debug, thiserror::Error)]
35pub enum Error {
36    #[error("operation `{id}` is not a local portable identity")]
37    InvalidOperation { id: String },
38
39    #[error(transparent)]
40    OperationPolicy(#[from] crate::operations::PolicyError),
41
42    #[error("operation `{id}` appears more than once in the catalog")]
43    DuplicateOperation { id: String },
44
45    #[error("operation `{id}` uses the reserved facility namespace")]
46    ReservedOperation { id: String },
47
48    #[error(transparent)]
49    Config(#[from] crate::ConfigError),
50
51    #[error(transparent)]
52    Identifier(#[from] crate::IdentifierError),
53
54    #[error(transparent)]
55    Message(#[from] crate::MessageError),
56
57    #[error(transparent)]
58    Registration(#[from] crate::RegistrationError),
59
60    #[error(transparent)]
61    Scan(#[from] crate::ScanError),
62
63    #[error(transparent)]
64    Value(#[from] crate::ValueError),
65
66    #[error("invalid {field}: {reason}")]
67    InvalidInput { field: &'static str, reason: &'static str },
68
69    #[error("{resource} capacity is exhausted")]
70    ResourceExhausted { resource: &'static str },
71
72    #[error("positions belong to different store histories")]
73    DifferentHistory,
74
75    #[error("{operation} found a corrupt stored value: {source}")]
76    Corrupt {
77        operation: &'static str,
78
79        #[source]
80        source: crate::MessageError,
81    },
82}
83
84/* === Traits === */
85
86/* === Implementations === */
87
88/* === Public Functions === */
89
90/* === Private Functions === */
91
92/* === Tests === */