1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use {
crate::{
core::{self, deser, storage, workspace},
Addr,
},
std::io,
};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("unhandled error: `{0}`")]
Unhandled(String),
#[error("fixity encountered an internal error: {source}")]
Internal {
#[from]
source: Internal,
},
#[error("fixity repository was not found")]
RepositoryNotFound,
#[error("no changes to write to repository")]
NoChangesToWrite,
#[error("a commit was attempted without any changes to commit")]
NoStageToCommit,
#[error("an action is unsupported when the HEAD is detached")]
DetachedHead,
#[error("cannot replace root data structure with non-map")]
CannotReplaceRootMap,
#[error("an address if dangling: `{message}`")]
DanglingAddr {
message: String,
addr: Option<Addr>,
},
#[error("data type error: {0}")]
Type(#[from] Type),
#[error("builder error: `{message}`")]
Builder { message: String },
#[error("prolly error: `{message}`")]
Prolly { message: String },
#[error("prolly@`{addr}`, error: `{message}`")]
ProllyAddr { addr: Addr, message: String },
#[error("store error: `{0}`")]
Storage(#[from] storage::Error),
#[error("io error: `{0}`")]
Io(#[from] io::Error),
#[error("reading input error: `{err}`")]
IoInputRead { err: io::Error },
#[error(
"storage wrote {got} bytes,
but was expected to write {expected} bytes"
)]
IncompleteWrite { got: usize, expected: usize },
#[error("deser error: `{0}`")]
Deser(#[from] deser::Error),
#[cfg(feature = "serde_json")]
#[error("serde json error: `{0}`")]
SerdeJson(#[from] serde_json::error::Error),
#[cfg(feature = "borsh")]
#[error("borsh error: `{0:?}`")]
Borsh(std::io::Error),
#[cfg(feature = "borsh")]
#[error("addr:{addr}, borsh error: `{err:?}`")]
BorshAddr { addr: Addr, err: std::io::Error },
#[cfg(feature = "cjson")]
#[error("cjson error: `{0:?}`")]
Cjson(cjson::Error),
}
#[derive(Debug, thiserror::Error)]
pub enum Internal {
#[error("fixity failed to initialize a new repository: {source}")]
Init {
#[from]
source: core::fixity::InitError,
},
#[error("head: `{source}`")]
Workspace {
#[from]
source: workspace::Error,
},
#[error("primitive: `{0}`")]
Primitive(String),
#[error("path: `{0}`")]
Path(String),
#[error("input/output error: `{0}`")]
Io(String),
}
#[cfg(feature = "cjson")]
impl From<cjson::Error> for Error {
fn from(err: cjson::Error) -> Self {
Self::Cjson(err)
}
}
impl From<workspace::Error> for Error {
fn from(err: workspace::Error) -> Self {
Self::Internal { source: err.into() }
}
}
impl From<core::fixity::InitError> for Error {
fn from(err: core::fixity::InitError) -> Self {
Self::Internal { source: err.into() }
}
}
#[derive(Debug, thiserror::Error)]
pub enum Type {
#[error("expected a Value of a specific type, got another")]
UnexpectedValueVariant {
at_segment: Option<String>,
at_addr: Option<Addr>,
},
}