extern crate glium;
extern crate core;
extern crate std;
use std::error::Error;
#[derive(Debug,Copy,Clone)]
pub enum ShapeCreationError {
VertexBufferCreationError(glium::vertex::BufferCreationError),
NotEnoughDivisionsInU,
NotEnoughDivisionsInV,
}
impl std::error::Error for ShapeCreationError {
fn description(&self) -> &str {
match self {
&ShapeCreationError::VertexBufferCreationError(ref err) => err.description(),
&ShapeCreationError::NotEnoughDivisionsInU => "Not enough divisions in the u axis",
&ShapeCreationError::NotEnoughDivisionsInV => "Not enough divisions in the v axis",
}
}
fn cause(&self) -> Option<&Error> {
match self {
&ShapeCreationError::VertexBufferCreationError(ref error) => Some(error),
_ => None,
}
}
}
impl From<glium::vertex::BufferCreationError> for ShapeCreationError {
fn from(error: glium::vertex::BufferCreationError) -> Self {
ShapeCreationError::VertexBufferCreationError(error)
}
}
impl core::fmt::Display for ShapeCreationError {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(fmt, "{}", self.description())
}
}