forge
Explore
Log in

Don't you dare go Hollow

in

Clone
★ 0

0 watching0 forksRustAGPL-3.0528.7 KiB9215377Tahinli27 days ago37 commits

error.rs37 lines, 1.4 KiBHistoryRawDownload
1//! The error type for `in-core`. `Invalid` and `Conflict` carry text meant for the user; every other
2//! variant becomes a generic 500 page with the cause logged.
3
4/// Every failure `in-core` reports.
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 /// A filesystem operation failed.
8 #[error("io error: {0}")]
9 Io(#[from] std::io::Error),
10 /// The database rejected or failed a statement.
11 #[error("database error: {0}")]
12 Database(String),
13 /// A schema migration could not be applied.
14 #[error("migration error: {0}")]
15 Migration(String),
16 /// The configuration file is unreadable, malformed or fails validation.
17 #[error("config error: {0}")]
18 Config(String),
19 /// Sealing, opening, hashing or the instance key failed.
20 #[error("crypto error: {0}")]
21 Crypto(String),
22 /// The requested row does not exist, or the viewer may not know that it exists.
23 #[error("not found")]
24 NotFound,
25 /// The write clashes with existing state, such as a name that is already taken.
26 #[error("conflict: {0}")]
27 Conflict(String),
28 /// The actor is known but may not do this.
29 #[error("forbidden: {0}")]
30 Forbidden(String),
31 /// The input is malformed or breaks a rule.
32 #[error("invalid value: {0}")]
33 Invalid(String),
34}
35
36/// Shorthand for results carrying [`Error`].
37pub type Result<T> = std::result::Result<T, Error>;