use std::{
error::Error,
fmt::{
Display,
Formatter,
Result
}
};
#[derive(Debug)]
pub struct GraphicsError {
msg: String
}
impl GraphicsError {
pub(crate) fn new(msg: &str) -> Self {
Self {
msg: msg.to_owned()
}
}
}
impl Display for GraphicsError {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "{}", self.msg)
}
}
impl Error for GraphicsError {}
#[cfg(test)]
mod tests {
use super::GraphicsError;
#[test]
fn graphics_error() {
assert_eq!(GraphicsError::new("Not enough!").to_string(), "Not enough!");
}
}