2022-10-22 14:37:47 +11:00
|
|
|
use std::convert::Infallible;
|
2022-10-21 16:12:17 +11:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use thiserror::Error;
|
|
|
|
|
2022-12-01 14:50:57 +11:00
|
|
|
/// Error type for source preprocessing.
|
2022-10-21 16:12:17 +11:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum PreprocessError {
|
2022-12-01 14:50:57 +11:00
|
|
|
/// The version header was not found in the source file.
|
2022-10-21 16:12:17 +11:00
|
|
|
#[error("the version header was missing")]
|
|
|
|
MissingVersionHeader,
|
2022-12-01 14:50:57 +11:00
|
|
|
/// An IO error occurred when reading the source file.
|
2022-10-21 16:12:17 +11:00
|
|
|
#[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.
|
2022-10-21 16:12:17 +11:00
|
|
|
#[error("unexpected end of file")]
|
|
|
|
UnexpectedEof,
|
2022-12-01 14:50:57 +11:00
|
|
|
/// Unexpected end of line when reading the source file.
|
2022-10-21 16:12:17 +11:00
|
|
|
#[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.
|
2022-10-22 17:54:06 +11:00
|
|
|
#[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`.
|
2022-10-22 17:54:06 +11:00
|
|
|
#[error("stage must be either vertex or fragment")]
|
|
|
|
InvalidStage,
|
2022-10-21 16:12:17 +11:00
|
|
|
}
|
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
|
|
|
}
|