From 513a86423369e813dbf99bf3c90afc6f8cfb089f Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sun, 7 Apr 2019 13:54:19 -0500 Subject: [PATCH] Environment variable failure can fallback --- lib/dhall/ast.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/dhall/ast.rb b/lib/dhall/ast.rb index 853b6ab..1f4333c 100644 --- a/lib/dhall/ast.rb +++ b/lib/dhall/ast.rb @@ -1075,12 +1075,16 @@ module Dhall end def resolve(resolver) - val = ENV.fetch(@var) - if val =~ /\Ahttps?:\/\// - URI.from_uri(URI(value)) - else - Path.from_string(val) - end.resolve(resolver) + Promise.resolve(nil).then do + val = ENV.fetch(@var) do + raise ImportFailedException, "No ENV #{@var}" + end + if val =~ /\Ahttps?:\/\// + URI.from_uri(URI(value)) + else + Path.from_string(val) + end.resolve(resolver) + end end def as_json -- 2.38.5