forge
Explore
Log in

Don't you dare go Hollow

im

Clone
★ 0

0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits

error.rs42 lines, 1.6 KiBHistoryRawDownload
1//! The error type shared by every `im-core` module.
2//!
3//! `Invalid` and `Conflict` carry text that is safe to show the user. Every other variant is a
4//! server-side failure: the web layer answers with a generic page and logs the cause.
5
6/// Everything `im-core` can fail with.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 /// A filesystem operation failed.
10 #[error("io error: {0}")]
11 Io(#[from] std::io::Error),
12 /// The database rejected a statement or could not be opened.
13 #[error("database error: {0}")]
14 Database(String),
15 /// A migration could not be recorded or applied.
16 #[error("migration error: {0}")]
17 Migration(String),
18 /// The configuration file is unreadable or breaks a cross-field rule.
19 #[error("config error: {0}")]
20 Config(String),
21 /// Sealing, opening, hashing or the instance key failed.
22 #[error("crypto error: {0}")]
23 Crypto(String),
24 /// The row asked for does not exist, or the caller may not know that it does.
25 #[error("not found")]
26 NotFound,
27 /// The request clashes with existing state, such as a taken email address. Shown to the user.
28 #[error("conflict: {0}")]
29 Conflict(String),
30 /// The caller may not do this. Shown to the user.
31 #[error("forbidden: {0}")]
32 Forbidden(String),
33 /// The input is malformed or breaks a policy. Shown to the user.
34 #[error("invalid value: {0}")]
35 Invalid(String),
36 /// A picture has a side longer than the decoder accepts. The web layer shows its own message for it.
37 #[error("picture too large")]
38 PictureTooLarge,
39}
40
41/// `Result` with the crate error.
42pub type Result<T> = std::result::Result<T, Error>;