use std::error::Error;
use std::fmt::{Debug, Display, Formatter, Result};
pub struct ProjectNotFound {
pub name: String,
}
impl ProjectNotFound {
pub fn new(name: &str) -> Self {
Self {
name: name.to_string(),
}
}
}
pub struct InvalidProperty {
pub entity: String,
pub property: String,
}
impl InvalidProperty {
pub fn new(entity: &str, property: &str) -> Self {
Self {
entity: entity.to_string(),
property: property.to_string(),
}
}
}
impl Display for ProjectNotFound {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, r#"Could not find project "{}"."#, &self.name)
}
}
impl Display for InvalidProperty {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(
f,
r#"Invalid value for property "{}" in {}."#,
&self.property, &self.entity
)
}
}
impl Debug for ProjectNotFound {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "ProjectNotFound: {}", &self)
}
}
impl Debug for InvalidProperty {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "InvalidProperty: {}", &self)
}
}
impl Error for ProjectNotFound {}
impl Error for InvalidProperty {}