Exception: Cassanity::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Error

Public: Initializes an Error.

args - The Hash of arguments.

:original - The Exception being wrapped (optional).

Returns the duplicated String.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cassanity/error.rb', line 12

def initialize(args = {})
  if args.is_a?(String)
    @message = args
  else
    @original = args.fetch(:original) { $! }
    @message = args.fetch(:message) {
      if @original
        "Original Exception: #{@original.class}: #{@original.message}"
      else
        "Something truly horrible went wrong"
      end
    }
  end

  super @message
end

Instance Attribute Details

#originalObject (readonly)

Public: The original error this exception is wrapping.



4
5
6
# File 'lib/cassanity/error.rb', line 4

def original
  @original
end