diff options
author | David RodrÃguez <[email protected]> | 2024-09-05 20:07:51 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-09-11 11:28:12 +0000 |
commit | 89eba5074e8ffc28a54646d40f6915d279be367d () | |
tree | dff405a613a61516cd5c7ec9728ab5c68fc043fc /lib | |
parent | 1d72b3bd1a1ebaaca89b50a8b6f391b7358c0986 (diff) |
[rubygems/rubygems] Only raise DSLError during Gemfile parsing when it's actually useful
DSLError prints the specific line in a Gemfile where the error was raised. That's helpful when the error was explicitly raised by the Gemfile DSL or, in the case it's implicitly raised, when the offending code lives right in the Gemfile. If it's an internal error, or something buried dowm in user code called from the Gemfile, `DSLError` is not helpful since it hides the actual culprit. This commit tries to only raise `DSLError` in the cases mentioned above and otherwise let the original error be raised. https://.com/rubygems/rubygems/commit/b30ff5a682
-rw-r--r-- | lib/bundler/dsl.rb | 16 | ||||
-rw-r--r-- | lib/bundler/errors.rb | 2 | ||||
-rw-r--r-- | lib/bundler/ruby_version.rb | 8 |
3 files changed, 19 insertions, 7 deletions
@@ -45,11 +45,15 @@ module Bundler with_gemfile(gemfile) do |current_gemfile| contents ||= Bundler.read_file(current_gemfile) instance_eval(contents, current_gemfile, 1) - rescue StandardError, ScriptError => e - message = "There was an error " \ - "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \ - "`#{File.basename current_gemfile}`: #{e.message}" - raise DSLError.new(message, current_gemfile, e.backtrace, contents) end end @@ -215,7 +219,7 @@ module Bundler end def (repo, options = {}) - raise ArgumentError, " sources require a block" unless block_given? _uri = @git_sources[""].call(repo) git_options = normalize_hash(options).merge("uri" => _uri) git_source = @sources.add_git_source(git_options) @@ -244,4 +244,6 @@ module Bundler status_code(39) end end @@ -23,7 +23,13 @@ module Bundler # specified must match the version. @versions = Array(versions).map do |v| - op, v = Gem::Requirement.parse(normalize_version(v)) op == "=" ? v.to_s : "#{op} #{v}" end |