diff options
Diffstat (limited to 'lib/bundler/cli/gem.rb')
-rw-r--r-- | lib/bundler/cli/gem.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index ebfaf75b8c..53cea7d754 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -28,6 +28,7 @@ module Bundler @target = SharedHelpers.pwd.join(gem_name) validate_ext_name if options[:ext] + validate_error_class if options[:error_class] end def run @@ -56,6 +57,7 @@ module Bundler :test => options[:test], :ext => options[:ext], :exe => options[:exe], + :error_class => options[:error_class], :bundler_version => bundler_dependency_version, :github_username => github_username.empty? ? "[USERNAME]" : github_username } @@ -242,6 +244,18 @@ module Bundler exit 1 end + def validate_error_class + error_class = options[:error_class] + + if (error = Object.const_get(error_class)) && !(error <= Exception) # rubocop:disable Style/InverseMethods + Bundler.ui.error "Invalid error class #{error_class}. Please use a class inheriting from Exception." + exit 1 + end + rescue NameError + Bundler.ui.error "Invalid class name #{error_class} for error class. Please provide an Exception subclass." + exit 1 + end + def open_editor(editor, file) thor.run(%(#{editor} "#{file}")) end |