use std::error::Error;
use std::fmt;
#[derive(Debug, Clone, PartialEq)]
pub enum SwapBuffersError {
ContextLost,
AlreadySwapped,
Unknown(u32),
}
impl fmt::Display for SwapBuffersError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
use std::error::Error;
write!(formatter, "{}", self.description())
}
}
impl Error for SwapBuffersError {
fn description(&self) -> &str {
match *self {
SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
SwapBuffersError::AlreadySwapped => {
"Buffers are already swapped, swap_buffers was called too many times"
}
SwapBuffersError::Unknown(_) => "Unknown error occurred",
}
}
fn cause(&self) -> Option<&dyn Error> {
None
}
}