Exception: Gem::OptionParser::ParseError
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
RuntimeError
|
|
Instance Chain:
self,
RuntimeError
|
|
Inherits: |
RuntimeError
|
Defined in: | lib/rubygems/optparse/lib/optparse.rb |
Overview
Base class of exceptions from ::Gem::OptionParser
.
Constant Summary
-
Reason =
Reason
which caused the error.'parse error'
Class Method Summary
Instance Attribute Summary
- #additional rw
- #args readonly
-
#reason
rw
Returns error reason.
- #reason=(value) rw
Instance Method Summary
- #inspect
-
#message
(also: #to_s)
Default stringizing method to emit standard error message.
-
#recover(argv)
Pushes back erred argument(s) to
argv
. - #set_backtrace(array)
- #set_option(opt, eq)
-
#to_s
Alias for #message.
Constructor Details
.new(*args, additional: nil) ⇒ ParseError
# File 'lib/rubygems/optparse/lib/optparse.rb', line 2026
def initialize(*args, additional: nil) @additional = additional @arg0, = args @args = args @reason = nil end
Class Method Details
.filter_backtrace(array)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2045
def self.filter_backtrace(array) unless $DEBUG array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~)) end array end
Instance Attribute Details
#additional (rw)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2035
attr_accessor :additional
#args (readonly)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2033
attr_reader :args
#reason (rw)
Returns error reason. Override this for I18N.
# File 'lib/rubygems/optparse/lib/optparse.rb', line 2068
def reason @reason || self.class::Reason end
#reason=(value) (rw)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2034
attr_writer :reason
Instance Method Details
#inspect
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2072
def inspect "#<#{self.class}: #{args.join(' ')}>" end
#message Also known as: #to_s
Default stringizing method to emit standard error message.
# File 'lib/rubygems/optparse/lib/optparse.rb', line 2079
def "#{reason}: #{args.join(' ')}#{additional[@arg0] if additional}" end
#recover(argv)
Pushes back erred argument(s) to argv
.
# File 'lib/rubygems/optparse/lib/optparse.rb', line 2040
def recover(argv) argv[0, 0] = @args argv end
#set_backtrace(array)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2052
def set_backtrace(array) super(self.class.filter_backtrace(array)) end
#set_option(opt, eq)
[ GitHub ]# File 'lib/rubygems/optparse/lib/optparse.rb', line 2056
def set_option(opt, eq) if eq @args[0] = opt else @args.unshift(opt) end self end
#to_s
Alias for #message.
# File 'lib/rubygems/optparse/lib/optparse.rb', line 2083
alias to_s