Exception: CmdParse::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cmdparse.rb

Overview

Base class for all cmdparse errors.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_reasonObject

Returns the error reason or ‘CmdParse error’ if it has not been set.



62
63
64
# File 'lib/cmdparse.rb', line 62

def self.get_reason
  @reason ||= 'CmdParse error'
end

.reason(reason) ⇒ Object

Sets the error reason for the subclass.



57
58
59
# File 'lib/cmdparse.rb', line 57

def self.reason(reason)
  @reason = reason
end

Instance Method Details

#messageObject

Returns the reason plus the original message.



67
68
69
70
# File 'lib/cmdparse.rb', line 67

def message
  str = super
  self.class.get_reason + (str.empty? ? "" : ": #{str}")
end