1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::__gl;
use crate::device::Device;
use crate::pipeline::{Pipeline, Shader};
use std::{error, fmt, result};
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Error {
OutOfMemory,
CompileError(Shader),
LinkError(Pipeline),
}
pub type Result<T> = result::Result<T, Error>;
impl Device {
pub(crate) unsafe fn get_error(&self) -> Result<()> {
let err = self.0.GetError();
match err {
__gl::OUT_OF_MEMORY => Err(Error::OutOfMemory),
_ => Ok(()),
}
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
match *self {
Error::OutOfMemory => write!(fmt, "OutOfMemory"),
Error::CompileError(_) => write!(fmt, "CompileError"),
Error::LinkError(_) => write!(fmt, "LinkError"),
}
}
}