mirror of
https://github.com/orhun/systeroid
synced 2024-10-06 15:49:09 +00:00
fix(parser): return error in the case of empty file vector
This commit is contained in:
parent
e8c7890f98
commit
2379c6ddf3
|
@ -12,6 +12,9 @@ pub enum Error {
|
|||
/// Error that may occur when the capture group does not exist.
|
||||
#[error("capture group does not exist")]
|
||||
CaptureError,
|
||||
/// Error that may occur when the glob pattern returns zero results.
|
||||
#[error("glob pattern has yielded no results")]
|
||||
EmptyFileListError,
|
||||
/// Error that may occur when a required file for parsing does not exist.
|
||||
#[error("required file missing: '{0}'")]
|
||||
MissingFileError(String),
|
||||
|
|
|
@ -45,6 +45,9 @@ impl<'a> Parser<'a> {
|
|||
)?
|
||||
.filter_map(StdResult::ok)
|
||||
.collect::<Vec<DirEntry>>();
|
||||
if glob_files.is_empty() {
|
||||
return Err(Error::EmptyFileListError);
|
||||
}
|
||||
self.required_files.iter().try_for_each(|file_name| {
|
||||
glob_files
|
||||
.iter()
|
||||
|
@ -53,7 +56,6 @@ impl<'a> Parser<'a> {
|
|||
.ok_or_else(|| Error::MissingFileError(file_name.to_string()))
|
||||
})?;
|
||||
for file in glob_files {
|
||||
println!("{:?}", file);
|
||||
let input = reader::read_to_string(file.path())?;
|
||||
let capture_group = self
|
||||
.regex
|
||||
|
|
Loading…
Reference in a new issue