1use std::fmt;
11
12#[derive(Debug)]
13pub enum BakeError {
14 Io(std::io::Error),
15 InvalidHdr(String),
16 InvalidSize(String),
17 UnsupportedFormat(u32),
18}
19
20impl fmt::Display for BakeError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 BakeError::Io(e) => write!(f, "I/O error: {e}"),
24 BakeError::InvalidHdr(s) => write!(f, "invalid HDR: {s}"),
25 BakeError::InvalidSize(s) => write!(f, "invalid size: {s}"),
26 BakeError::UnsupportedFormat(n) => write!(f, "unsupported VkFormat: {n}"),
27 }
28 }
29}
30
31impl std::error::Error for BakeError {
32 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
33 match self {
34 BakeError::Io(e) => Some(e),
35 _ => None,
36 }
37 }
38}
39
40impl From<std::io::Error> for BakeError {
41 fn from(e: std::io::Error) -> Self {
42 BakeError::Io(e)
43 }
44}