1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* SPDX-License-Identifier: LGPL-2.1-or-later OR MPL-2.0

Copyright (c) 2024 DorotaC
*/
/*! OpenGL errors.
*/

use gl;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
    #[error("Any")]
    Any(u32),
}

pub fn check<T>(result: T) -> Result<T, Error> {
    let err = unsafe { gl::GetError() };
    if err == gl::NO_ERROR {
        Ok(result)
    } else {
        Err(Error::Any(err))
    }
}