librashader/librashader-preprocess/src/error.rs

39 lines
1.4 KiB
Rust
Raw Normal View History

2022-10-22 14:37:47 +11:00
use std::convert::Infallible;
use std::path::PathBuf;
use thiserror::Error;
2022-12-01 14:50:57 +11:00
/// Error type for source preprocessing.
#[derive(Error, Debug)]
pub enum PreprocessError {
2022-12-01 14:50:57 +11:00
/// The version header was not found in the source file.
#[error("the version header was missing")]
MissingVersionHeader,
2022-12-01 14:50:57 +11:00
/// An IO error occurred when reading the source file.
#[error("the file was not found during resolution")]
IOError(PathBuf, std::io::Error),
2022-12-01 14:50:57 +11:00
/// Unexpected EOF when reading the source file.
#[error("unexpected end of file")]
UnexpectedEof,
2022-12-01 14:50:57 +11:00
/// Unexpected end of line when reading the source file.
#[error("unexpected end of line")]
UnexpectedEol(usize),
2022-12-01 14:50:57 +11:00
/// An error occurred when parsing a pragma statement.
2022-10-22 14:37:47 +11:00
#[error("error parsing pragma")]
PragmaParseError(String),
2022-12-01 14:50:57 +11:00
/// The given pragma was declared multiple times with differing values.
#[error("duplicate pragma found")]
DuplicatePragmaError(String),
2022-12-01 14:50:57 +11:00
/// The imaged format requested by the shader was unknown or not supported.
2022-10-22 14:37:47 +11:00
#[error("shader format is unknown or not found")]
2022-12-01 14:50:57 +11:00
UnknownImageFormat,
/// The stage declared by the shader source was not `vertex` or `fragment`.
#[error("stage must be either vertex or fragment")]
InvalidStage,
}
2022-10-22 14:37:47 +11:00
impl From<Infallible> for PreprocessError {
fn from(_: Infallible) -> Self {
unreachable!()
}
2022-10-23 15:59:18 +11:00
}