librashader_preprocess/
error.rs

1use librashader_common::map::ShortString;
2use std::convert::Infallible;
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Error type for source preprocessing.
7#[derive(Error, Debug)]
8pub enum PreprocessError {
9    /// The version header was not found in the source file.
10    #[error("the version header was missing")]
11    MissingVersionHeader,
12    /// An IO error occurred when reading the source file.
13    #[error("the file was not found during resolution")]
14    IOError(PathBuf, std::io::Error),
15    /// A known encoding was not found for the file.
16    #[error(
17        "a known encoding was not found for the file. supported encodings are UTF-8 and Latin-1"
18    )]
19    EncodingError(PathBuf),
20    /// Unexpected EOF when reading the source file.
21    #[error("unexpected end of file")]
22    UnexpectedEof,
23    /// Unexpected end of line when reading the source file.
24    #[error("unexpected end of line")]
25    UnexpectedEol(usize),
26    /// An error occurred when parsing a pragma statement.
27    #[error("error parsing pragma")]
28    PragmaParseError(String),
29    /// The given pragma was declared multiple times with differing values.
30    #[error("duplicate pragma found")]
31    DuplicatePragmaError(ShortString),
32    /// The image format requested by the shader was unknown or not supported.
33    #[error("shader format is unknown or not found")]
34    UnknownImageFormat,
35    /// The stage declared by the shader source was not `vertex` or `fragment`.
36    #[error("stage must be either vertex or fragment")]
37    InvalidStage,
38}
39
40impl From<Infallible> for PreprocessError {
41    fn from(_: Infallible) -> Self {
42        unreachable!()
43    }
44}