From 1981c758a29549979cc685423fa07f6d888bfb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 3 Jul 2024 16:49:32 +0200 Subject: [PATCH] fix: more info when module is outside of the root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- runtime/module_loader.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/runtime/module_loader.rs b/runtime/module_loader.rs index cd31e0ed..a98e9340 100644 --- a/runtime/module_loader.rs +++ b/runtime/module_loader.rs @@ -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));