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(transparent)]
37    OperationPolicy(#[from] crate::operations::PolicyError),
38
39    #[error("operation `{id}` appears more than once in the catalog")]
40    DuplicateOperation { id: String },
41
42    #[error("operation `{id}` uses the reserved facility namespace")]
43    ReservedOperation { id: String },
44
45    #[error(transparent)]
46    Config(#[from] crate::ConfigError),
47
48    #[error(transparent)]
49    Identifier(#[from] crate::IdentifierError),
50
51    #[error(transparent)]
52    Message(#[from] crate::MessageError),
53
54    #[error(transparent)]
55    Registration(#[from] crate::RegistrationError),
56
57    #[error(transparent)]
58    Scan(#[from] crate::ScanError),
59
60    #[error(transparent)]
61    Value(#[from] crate::ValueError),
62
63    #[error("invalid {field}: {reason}")]
64    InvalidInput { field: &'static str, reason: &'static str },
65
66    #[error("{resource} capacity is exhausted")]
67    ResourceExhausted { resource: &'static str },
68
69    #[error("positions belong to different store histories")]
70    DifferentHistory,
71
72    #[error("{operation} found a corrupt stored value: {source}")]
73    Corrupt {
74        operation: &'static str,
75
76        #[source]
77        source: crate::MessageError,
78    },
79}
80
81/* === Traits === */
82
83/* === Implementations === */
84
85/* === Public Functions === */
86
87/* === Private Functions === */
88
89/* === Tests === */