use flagset::FlagSet;
use thiserror::Error;
use crate::records::CheckFlag;
#[derive(Error, Debug)]
pub enum StoreError {
#[error("The store does not exist")]
DoesNotExist,
#[error("IO Error: {source}")]
Io {
#[from]
source: std::io::Error,
},
#[error("Could not deserialize the store from the loaded data: {source}")]
Load {
#[from]
source: bincode::Error,
},
#[error("Could not convert data to Utf8")]
Str {
#[from]
source: std::str::Utf8Error,
},
#[error("A subprocess ended non successfully")]
ProcessEndedWithoutSuccess,
#[error("Tried to load a store with an unsupported version")]
UnsupportedVersion,
#[error("Check has ambiguous flags: {0:?}")]
AmbiguousFlags(FlagSet<CheckFlag>),
#[error("Check is missing at least one of these flags: {0:?}")]
MissingFlag(FlagSet<CheckFlag>),
#[error("Tried to load a store version that does not exist: {0}")]
BadStoreVersion(u8),
#[error("Tried to save a readonly store")]
IsReadonly,
}
#[derive(Error, Debug)]
pub enum CheckError {
#[error("IO Error {source}")]
Io {
#[from]
source: std::io::Error,
},
#[cfg(feature = "ping")]
#[error("Ping Error: {source}")]
Ping {
#[from]
source: ping::Error,
},
#[cfg(feature = "http")]
#[error("Http Error: {source}")]
Http {
#[from]
source: curl::Error,
},
}
#[derive(Error, Debug)]
pub enum RunError {
#[error("Something went wrong with the store: {source}")]
StoreError {
#[from]
source: StoreError,
},
#[error("Something went wrong while analyzing: {source}")]
AnalysisError {
#[from]
source: AnalysisError,
},
#[error("IO Error: {source}")]
Io {
#[from]
source: std::io::Error,
},
#[error("Text Formatting error: {source}")]
Fmt {
#[from]
source: std::fmt::Error,
},
}
#[derive(Error, Debug)]
pub enum AnalysisError {
#[error("Something went wrong with the store: {source}")]
StoreError {
#[from]
source: StoreError,
},
#[error("Text Formatting error: {source}")]
Fmt {
#[from]
source: std::fmt::Error,
},
#[error("IO Error: {source}")]
Io {
#[from]
source: std::io::Error,
},
}