Skip to main content

lonca_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("git: {0}")]
6    Git(String),
7    #[error("io: {0}")]
8    Io(#[from] std::io::Error),
9    #[error("json: {0}")]
10    Json(#[from] serde_json::Error),
11    #[error("invalid: {0}")]
12    Invalid(String),
13    #[error("integrity: {0}")]
14    Integrity(String),
15    #[error("conflict: {0}")]
16    Conflict(String),
17    /// Data written by a newer (or unknown) version of Lonca.
18    #[error("unsupported: {0}")]
19    Unsupported(String),
20}
21
22pub type Result<T, E = Error> = std::result::Result<T, E>;
23
24#[cfg(feature = "store")]
25pub(crate) fn git<E: std::fmt::Display>(e: E) -> Error {
26    Error::Git(e.to_string())
27}