librashader/librashader-preprocess/src/error.rs

45 lines
1.6 KiB
Rust
Raw Normal View History

use librashader_common::map::ShortString;
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),
2023-01-29 03:58:59 +11:00
/// A known encoding was not found for the file.
2023-01-29 18:30:58 +11:00
#[error(
"a known encoding was not found for the file. supported encodings are UTF-8 and Latin-1"
)]
2023-01-29 03:58:59 +11:00
EncodingError(PathBuf),
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(ShortString),
2023-01-17 11:35:23 +11:00
/// The image 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
}