//! The error type shared by every `im-core` module. //! //! `Invalid` and `Conflict` carry text that is safe to show the user. Every other variant is a //! server-side failure: the web layer answers with a generic page and logs the cause. /// Everything `im-core` can fail with. #[derive(Debug, thiserror::Error)] pub enum Error { /// A filesystem operation failed. #[error("io error: {0}")] Io(#[from] std::io::Error), /// The database rejected a statement or could not be opened. #[error("database error: {0}")] Database(String), /// A migration could not be recorded or applied. #[error("migration error: {0}")] Migration(String), /// The configuration file is unreadable or breaks a cross-field rule. #[error("config error: {0}")] Config(String), /// Sealing, opening, hashing or the instance key failed. #[error("crypto error: {0}")] Crypto(String), /// The row asked for does not exist, or the caller may not know that it does. #[error("not found")] NotFound, /// The request clashes with existing state, such as a taken email address. Shown to the user. #[error("conflict: {0}")] Conflict(String), /// The caller may not do this. Shown to the user. #[error("forbidden: {0}")] Forbidden(String), /// The input is malformed or breaks a policy. Shown to the user. #[error("invalid value: {0}")] Invalid(String), /// A picture has a side longer than the decoder accepts. The web layer shows its own message for it. #[error("picture too large")] PictureTooLarge, } /// `Result` with the crate error. pub type Result = std::result::Result;