Do not throw error for files not found in lib_dirs (#4029)

This commit is contained in:
Jakub Žádník 2021-09-20 21:44:47 +03:00 committed by GitHub
parent b3b3cf0689
commit 349af05da8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View file

@ -69,13 +69,11 @@ pub fn source(args: CommandArgs) -> Result<OutputStream, ShellError> {
for lib_path in dir { for lib_path in dir {
match lib_path { match lib_path {
Ok(name) => { Ok(name) => {
let path = canonicalize_with(&source_file, name).map_err(|e| { let path = if let Ok(p) = canonicalize_with(&source_file, name) {
ShellError::labeled_error( p
format!("Can't load source file. Reason: {}", e.to_string()), } else {
"Can't load this file", continue;
filename.span(), };
)
})?;
if let Ok(contents) = std::fs::read_to_string(path) { if let Ok(contents) = std::fs::read_to_string(path) {
let result = script::run_script_standalone(contents, true, ctx, false); let result = script::run_script_standalone(contents, true, ctx, false);

View file

@ -61,12 +61,11 @@ fn find_source_file(
if let Some(dir) = lib_dirs { if let Some(dir) = lib_dirs {
for lib_path in dir.into_iter().flatten() { for lib_path in dir.into_iter().flatten() {
let path = canonicalize_with(&file, lib_path).map_err(|e| { let path = if let Ok(p) = canonicalize_with(&file, lib_path) {
ParseError::general_error( p
format!("Can't load source file. Reason: {}", e.to_string()), } else {
"Can't load this file".spanned(file_span), continue;
) };
})?;
if let Ok(contents) = std::fs::read_to_string(&path) { if let Ok(contents) = std::fs::read_to_string(&path) {
return parse(&contents, 0, scope); return parse(&contents, 0, scope);