#![forbid(unsafe_code)]
#![forbid(missing_docs)]
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ExporterError {
#[error("{0} was not set.")]
ArgNotSet(String),
#[cfg(feature = "bcrypt_cmd")]
#[error("bcrypt error while hashing password")]
BcryptHashingError(#[from] bcrypt::BcryptError),
#[cfg(feature = "auth")]
#[error("bcrypt error with password for user: {0}")]
BcryptValidationError(String),
#[error("HttpdError: {0}")]
HttpdError(#[from] crate::httpd::HttpdError),
#[cfg(feature = "auth")]
#[error("Invalid username: {0}")]
InvalidUsername(String),
#[error("std::io::Error")]
IoError(#[from] std::io::Error),
#[error("could not get jail name")]
JailError(jail::JailError),
#[error("jail_exporter must be run as root")]
NotRunningAsRoot,
#[error("error occurred while persisting metrics")]
PersistError(#[from] tempfile::PersistError),
#[error("error within Prometheus library")]
PrometheusError(#[from] prometheus::Error),
#[error("RACCT/RCTL: {0}")]
RctlUnavailable(String),
#[error("Failed to convert UTF-8 to String")]
Utf8Error(#[from] std::string::FromUtf8Error),
#[cfg(feature = "auth")]
#[error("Failed to read YAML configuration")]
YamlError(#[from] serde_yaml::Error),
}
impl From<jail::JailError> for ExporterError {
fn from(e: jail::JailError) -> Self {
Self::JailError(e)
}
}