Exception: Flows::Contract::Error

Inherits:
Error
  • Object
show all
Defined in:
lib/flows/contract/error.rb

Overview

Class for Type errors.

Since:

  • 0.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, value_error) ⇒ Error

Returns a new instance of Error.

Parameters:

  • value (Object)

    checked value

  • value_error (String)

    error message

Since:

  • 0.4.0



9
10
11
12
# File 'lib/flows/contract/error.rb', line 9

def initialize(value, value_error)
  @value = value
  @value_error = value_error
end

Instance Attribute Details

#valueObject (readonly)

Since:

  • 0.4.0



5
6
7
# File 'lib/flows/contract/error.rb', line 5

def value
  @value
end

#value_errorObject (readonly)

Since:

  • 0.4.0



5
6
7
# File 'lib/flows/contract/error.rb', line 5

def value_error
  @value_error
end

Instance Method Details

#messageObject

Since:

  • 0.4.0



14
15
16
17
18
19
20
21
# File 'lib/flows/contract/error.rb', line 14

def message
  [
    'type check failed for:',
    "    `#{@value.inspect}`",
    "---\n",
    @value_error
  ].join("\n")
end