aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-07-14 22:00:09 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-07-20 09:35:41 -0500
commit85f7252bc4e57c1d85e5fb1c2a808b90e209bb2b (patch)
treeb1cd66888db41b92f519f0734a62b644106129aa /lib
parent396c9a5d6da3835ce21cccaadd5ae4fb0e781dba (diff)
downloadbundler-85f7252bc4e57c1d85e5fb1c2a808b90e209bb2b.tar.gz
[Bundler] Use DSLError when eval-ing a gemspec fails
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler.rb10
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/friendly_errors.rb2
3 files changed, 5 insertions, 9 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 07064dad..bedc0464 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -401,17 +401,13 @@ module Bundler
def eval_gemspec(path, contents)
eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
rescue ScriptError, StandardError => e
- original_line = e.backtrace.find {|line| line.include?(path.to_s) }
- msg = String.new
- msg << "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
- msg << " from\n #{original_line}" if original_line
- msg << "\n"
+ msg = "There was an error while loading `#{path.basename}`: #{e.message}"
if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
- msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
+ msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
end
- raise GemspecError, msg
+ raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
end
def configure_gem_home_and_path
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 0436b58f..58ff752f 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -417,7 +417,7 @@ module Bundler
# TODO: 2.0 upgrade from setting to default
if Bundler.settings[:disable_multisource]
- raise GemspecError, "Warning: this Gemfile contains multiple primary sources. " \
+ raise GemfileError, "Warning: this Gemfile contains multiple primary sources. " \
"Each source after the first must include a block to indicate which gems " \
"should come from that source. To downgrade this error to a warning, run " \
"`bundle config --delete disable_multisource`"
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index a01c03f2..b6c22ee6 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -12,7 +12,7 @@ module Bundler
when YamlSyntaxError
Bundler.ui.error error.message
Bundler.ui.trace error.orig_exception
- when Dsl::DSLError
+ when Dsl::DSLError, GemspecError
Bundler.ui.error error.message
when GemRequireError
Bundler.ui.error error.message