use std::fmt;
#[derive(Debug, Clone, PartialEq)]
pub enum OpticErrorKind {
Init,
OpenGL,
Shader,
Asset,
File,
Framebuffer,
Custom,
}
#[derive(Debug, Clone)]
pub struct OpticError {
pub kind: OpticErrorKind,
pub msg: String,
}
impl fmt::Display for OpticError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "optic error: {}", self.msg)
}
}
impl OpticError {
pub fn new(kind: OpticErrorKind, msg: &str) -> Self {
Self {
kind,
msg: msg.to_string(),
}
}
pub fn custom(msg: &str) -> Self {
Self {
kind: OpticErrorKind::Custom,
msg: msg.to_string(),
}
}
}
pub type OpticResult<T> = Result<T, OpticError>;