1use std::error::Error;
2use std::ffi::NulError;
3use std::fmt::{
4 self,
5 Display,
6 Formatter,
7};
8use std::io;
9
10#[derive(Debug)]
12#[non_exhaustive]
13pub enum ErrorKind {
14 UnknownError,
16 GeneralError(String),
18 #[cfg(feature = "image-loading")]
20 ImageError(::image::ImageError),
21 IoError(io::Error),
23 FontParseError,
25 NoFontFound,
27 FontInfoExtracionError,
29 FontSizeTooLargeForAtlas,
31 ShaderCompileError(String),
33 ShaderLinkError(String),
35 RenderTargetError(String),
37 ImageIdNotFound,
39 ImageUpdateOutOfBounds,
41 ImageUpdateWithDifferentFormat,
43 UnsuportedImageFromat,
45}
46
47impl Display for ErrorKind {
48 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
49 write!(f, "canvas error")
50 }
51}
52
53#[cfg(feature = "image-loading")]
54impl From<::image::ImageError> for ErrorKind {
55 fn from(error: ::image::ImageError) -> Self {
56 Self::ImageError(error)
57 }
58}
59
60impl From<io::Error> for ErrorKind {
61 fn from(error: io::Error) -> Self {
62 Self::IoError(error)
63 }
64}
65
66impl From<NulError> for ErrorKind {
67 fn from(error: NulError) -> Self {
68 Self::GeneralError(error.to_string())
69 }
70}
71
72impl Error for ErrorKind {}