Module: Derelict::Exception::OptionalReason

Overview

An exception that has a message and optional additional reason

The reason can be passed to the constructor (if desired). When a reason is passed, it’s appended to the default message. If no reason is passed, the default message is used.

Instance Method Summary collapse

Instance Method Details

#initialize(reason = nil) ⇒ Object

Initializes a new instance of this exception, with a reason

* reason: Optional reason to add to the default error message
          (optional, the default message will be used if no
          reason is provided)


14
15
16
17
18
19
20
# File 'lib/derelict/exception/optional_reason.rb', line 14

def initialize(reason = nil)
  if reason.nil?
    super default_message
  else
    super "#{default_message}: #{reason}"
  end
end