Skip to content

Commit

Permalink
fix: more info when module is outside of the root
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos committed Jul 3, 2024
1 parent cfd40e2 commit 1981c75
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions runtime/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,21 @@ impl ModuleLoader for ZinniaModuleLoader {
));
} else {
let mut msg = if module_specifier.scheme() == "file" && module_root.is_some() {
format!("Cannot import files outside of module root directory {}. ", module_root.unwrap().display())
let module_desc = match module_specifier.to_file_path() {
Ok(m) => format!("Module file path: {}.", m.display()),
Err(_) => "(Cannot convert the module specifier to a file path.)".to_string(),
};
format!(
"Cannot import files outside of module root directory {}.\n{}",
module_root.unwrap().display(),
module_desc
)
} else {
"Zinnia supports importing from relative paths only. ".to_string()
};
msg.push_str(module_specifier.as_str());
msg.push_str(&format!("\nModule URL: {spec_str}"));
if let Some(referrer) = &maybe_referrer {
msg.push_str(" imported from ");
msg.push_str("\nImported from ");
msg.push_str(referrer.as_str());
}
return Err(anyhow!(msg));
Expand Down

0 comments on commit 1981c75

Please sign in to comment.