Class: Cuprum::Error

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

Overview

Wrapper class for encapsulating an error state for a failed Cuprum result. Additional details can be passed by setting the #message or by using a subclass of Cuprum::Error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String) (defaults to: nil)

    Optional message describing the nature of the error.



15
16
17
# File 'lib/cuprum/error.rb', line 15

def initialize(message: nil)
  @message = message
end

Instance Attribute Details

#messageString (readonly)

Returns Optional message describing the nature of the error.

Returns:

  • (String)

    Optional message describing the nature of the error.



20
21
22
# File 'lib/cuprum/error.rb', line 20

def message
  @message
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true if the other object has the same class and message; otherwise false.

Parameters:

Returns:

  • (Boolean)

    true if the other object has the same class and message; otherwise false.



26
27
28
29
# File 'lib/cuprum/error.rb', line 26

def ==(other)
  other.instance_of?(self.class) &&
    comparable_properties.all? { |prop| send(prop) == other.send(prop) }
end