From 8cfb6d563d26abb2fa80124eda2231eb05c7f3e6 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Nov 2020 18:59:01 +0000 Subject: feat: add location to import error messages This is crude but helpful. See #40 --- dhall/src/semantics/resolve/resolve.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'dhall/src/semantics/resolve') diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs index 614ea22..68b899c 100644 --- a/dhall/src/semantics/resolve/resolve.rs +++ b/dhall/src/semantics/resolve/resolve.rs @@ -411,9 +411,17 @@ fn resolve_with_env( // Resolve this import, making sure that recursive imports don't cycle back to the // current one. - let typed = env.with_cycle_detection(location.clone(), |env| { + let res = env.with_cycle_detection(location.clone(), |env| { resolve_one_import(env, &import, location.clone(), span.clone()) - })?; + }); + let typed = match res { + Ok(typed) => typed, + Err(e) => mkerr( + ErrorBuilder::new("error") + .span_err(span.clone(), e.to_string()) + .format(), + )?, + }; // Add the resolved import to the caches check_hash(&import, &typed, span)?; -- cgit v1.2.3