glyphon/src/error.rs

41 lines
982 B
Rust
Raw Normal View History

2022-10-06 12:13:43 -04:00
use std::{
error::Error,
fmt::{self, Display, Formatter},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PrepareError {
AtlasFull,
}
impl Display for PrepareError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
2022-10-18 11:34:06 -04:00
write!(f, "Prepare error: glyph texture atlas is full")
2022-10-06 12:13:43 -04:00
}
}
impl Error for PrepareError {}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RenderError {
RemovedFromAtlas,
ScreenResolutionChanged,
}
impl Display for RenderError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
RenderError::RemovedFromAtlas => {
2022-10-18 11:34:06 -04:00
write!(
f,
"Render error: glyph no longer exists within the texture atlas"
)
2022-10-06 12:13:43 -04:00
}
RenderError::ScreenResolutionChanged => write!(
f,
2022-10-18 11:34:06 -04:00
"Render error: screen resolution changed since last `prepare` call"
2022-10-06 12:13:43 -04:00
),
}
}
}