use crate::arguments::App;
use std::fmt::{Debug, Display};
pub struct MaximaError {
pub maximum: [f64; 3],
pub atom: usize,
pub distance: f64,
}
impl Display for MaximaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "")
}
}
impl Debug for MaximaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "")
}
}
pub struct VacuumError {
pub vacuum_tolerance: f64,
pub density: f64,
}
impl Display for VacuumError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Vacuum tolerance ({}) is higher than maximum value of density ({}).",
self.vacuum_tolerance, self.density
)
}
}
impl Debug for VacuumError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}
pub enum ArgumentError<'a> {
NotFlag(String),
Unparsable(String, String, String),
NoValue(String),
TooManyValues(String, usize, usize),
NotValidValue(String, String),
MissingDependant(String, String),
WrongFileType(String, String),
NoFile(&'a App),
ShortHelp(&'a App),
LongHelp(&'a App),
}
impl Display for ArgumentError<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NotFlag(flag) => {
write!(f, "The flag: {} does not exist", flag)
}
Self::Unparsable(flag, value, typ) => write!(
f,
"The supplied value \"{}\" for the option \"{}\" is unparsable as a {}.",
value, flag, typ
),
Self::NoValue(flag) => write!(
f,
"The option \"{}\" requires a value to be supplied.",
flag
),
Self::TooManyValues(flag, max, supplied) => write!(
f,
"Option \"{}\" was supplied {} times, the maximum allowed is \"{}\".",
flag, supplied, max
),
Self::NotValidValue(flag, value) => write!(
f,
"The value \"{}\" is not valid input for the option \"{}\".",
value, flag
),
Self::MissingDependant(flag, dependant) => write!(
f,
"The option \"{}\" requires the option \"{}\" to also be set.",
flag, dependant
),
Self::WrongFileType(flag, file_type) => write!(
f,
"The option \"{}\" cannot be set for the file type \"{}\".",
flag, file_type
),
Self::NoFile(app) => write!(f, "No file supplied.\n\n{}", app),
Self::ShortHelp(app) => write!(f, "{}", app),
Self::LongHelp(app) => write!(f, "{:?}", app),
}
}
}
impl Debug for ArgumentError<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}