diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-04-05 08:56:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 08:56:07 +0900 |
commit | d20fde87dded67effba7b08ee107557995a801c5 (patch) | |
tree | 9d54e1515b68bb3833dc254796edca17b9010086 | |
parent | ca1b131b3ee5c649959e8f8c856487f795e3b28f (diff) | |
parent | 20a633028eeba401b3148b33f53df8af1aaa5d19 (diff) | |
download | psych-d20fde87dded67effba7b08ee107557995a801c5.tar.gz |
Merge pull request #557 from XrXr/better-download-error
Improve libyaml source downloading error messages
-rw-r--r-- | ext/psych/extconf.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb index 795a050..b9cd120 100644 --- a/ext/psych/extconf.rb +++ b/ext/psych/extconf.rb @@ -19,10 +19,16 @@ if yaml_source == true # search the latest libyaml source under $srcdir yaml_source = Dir.glob("#{$srcdir}/yaml{,-*}/").max_by {|n| File.basename(n).scan(/\d+/).map(&:to_i)} unless yaml_source - require_relative '../../tool/extlibs.rb' - extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir)) - unless extlibs.process_under($srcdir) - raise "failed to download libyaml source" + download_failure = "failed to download libyaml source" + begin + require_relative '../../tool/extlibs.rb' + extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir)) + unless extlibs.process_under($srcdir) + raise download_failure + end + rescue + # Implicitly captures Exception#cause. Newer rubies show it in the backtrace. + raise download_failure end yaml_source, = Dir.glob("#{$srcdir}/yaml-*/") raise "libyaml not found" unless yaml_source |