Skip to content

Commit

Permalink
rusty: return Err when input file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
hadizamani021 committed Jun 15, 2024
1 parent 44df0db commit 53daf8a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler/plc_project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::{
path::{Path, PathBuf},
};

use anyhow::{Context, Result};
use glob::glob;

use crate::{
build_config::{LinkageInfo, ProjectConfig},
object::Object,
};
use anyhow::{Context, Result};
use glob::glob;
use plc_diagnostics::diagnostics::Diagnostic;

use plc::output::FormatOption;
use source_code::{SourceContainer, SourceType};
Expand Down Expand Up @@ -309,8 +309,11 @@ fn resolve_file_paths(location: Option<&Path>, inputs: Vec<PathBuf>) -> Result<V
for input in &inputs {
let input = location.map(|it| it.join(input)).unwrap_or(input.to_path_buf());
let path = &input.to_string_lossy();
let paths = glob(path).context(format!("Failed to read glob pattern {path}"))?;
if !input.exists() {
return Err(Diagnostic::new(format!("{} does not exist.", path)).into());
}

let paths = glob(path).context(format!("Failed to read glob pattern {path}"))?;
for p in paths {
let path = p.context("Illegal Path")?;
sources.push(path);
Expand Down

0 comments on commit 53daf8a

Please sign in to comment.