damc f9e93d18bd ppErrorPreprocess Make use of the existing Error::Preprocess
Before this commit, inputs with invalid pp syntax are reported using
`Error::Parse` which is also used to report invalid post-pp syntax.
In svlint/svls, `Error::Parse` is reported to the user as "parse error"
without specifying if that's pre or post pp.
This commit makes it possible for future versions of svlint/svls to report
"preprocess error", thus helping users to identify pp issues.

- `Error::Preprocess` appears to be defined but unused.
- Add the argument `Option<(PathBuf, usize)>` to `Error::Preprocess`, same
  as `Error::Parse`.
- Update `preprocess_str()` to use `Error::Preprocess` in all 5 instances.
2022-10-26 19:43:23 +02:00

45 lines
958 B
Rust

use std::path::PathBuf;
use thiserror::Error;
// -----------------------------------------------------------------------------
#[derive(Error, Debug)]
pub enum Error {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("File error: {path:?}")]
File {
#[source]
source: std::io::Error,
path: PathBuf,
},
#[error("Include error")]
Include {
#[from]
source: Box<Error>,
},
#[error("Parse error: {0:?}")]
Parse(Option<(PathBuf, usize)>),
#[error("Preprocess error: {0:?}")]
Preprocess(Option<(PathBuf, usize)>),
#[error("Define argument not found: {0}")]
DefineArgNotFound(String),
#[error("Define not found: {0}")]
DefineNotFound(String),
#[error("Define must have argument")]
DefineNoArgs,
#[error("Exceed recursive limit")]
ExceedRecursiveLimit,
#[error("Include line can't have other items")]
IncludeLine,
}