Exception: ValidatorFn::Error

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

Direct Known Subclasses

MissingKey

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg) ⇒ Error

Returns a new instance of Error.



5
6
7
8
# File 'lib/validator_fn/error.rb', line 5

def initialize(msg)
  @my_msg = msg
  super(msg)
end

Instance Attribute Details

#my_msgObject (readonly)

Returns the value of attribute my_msg.



3
4
5
# File 'lib/validator_fn/error.rb', line 3

def my_msg
  @my_msg
end

Instance Method Details

#message(indent = 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/validator_fn/error.rb', line 10

def message(indent = 0)
  if cause
    cause_msg = if cause.kind_of?(Error)
        cause.message(indent + 1)
      else
        cause.message
      end
    my_msg + "\n" + ("  " * (indent + 1)) + cause_msg
  else
    my_msg
  end
end