Ruby 2.4

OptionParser::ParseError

class OptionParser::ParseError

父类:RuntimeError

来自OptionParser的异常基类。

常量

Reason

导致错误的原因。

属性

argsR

reasonW

公共类方法

filter_backtrace(array) Show source

# File lib/optparse.rb, line 1966 def self.filter_backtrace(array) unless $DEBUG array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~)) end array end

new(*args) Show source

# File lib/optparse.rb, line 1950 def initialize(*args) @args = args @reason = nil end

公共实例方法

inspect() Show source

# File lib/optparse.rb, line 1993 def inspect "#<#{self.class}: #{args.join(' ')}>" end

message() Show source

默认字符串化方法发出标准错误信息。

# File lib/optparse.rb, line 2000 def message reason + ': ' + args.join(' ') end

另外别名为:to_s

reason() Show source

返回错误原因。覆盖此为I18N。

# File lib/optparse.rb, line 1989 def reason @reason || self.class::Reason end

recover(argv) Show source

将错误的参数推回argv

# File lib/optparse.rb, line 1961 def recover(argv) argv[0, 0] = @args argv end

set_backtrace(array) Show source

调用超类方法Exception#set_backtrace

# File lib/optparse.rb, line 1973 def set_backtrace(array) super(self.class.filter_backtrace(array)) end

set_option(opt, eq) Show source

# File lib/optparse.rb, line 1977 def set_option(opt, eq) if eq @args[0] = opt else @args.unshift(opt) end self end

to_s()

message 的别名