Exception: Flows::Plugin::OutputContract::ContractError

Inherits:
Error
  • Object
show all
Defined in:
lib/flows/plugin/output_contract/errors.rb

Overview

Raised when result's data violates contract

Since:

  • 0.4.0

Instance Method Summary collapse

Constructor Details

#initialize(klass, result, error) ⇒ ContractError

Returns a new instance of ContractError.

Since:

  • 0.4.0



20
21
22
23
24
# File 'lib/flows/plugin/output_contract/errors.rb', line 20

def initialize(klass, result, error)
  @klass = klass
  @result = result
  @error = error
end

Instance Method Details

#messageObject

Since:

  • 0.4.0



26
27
28
29
30
31
32
33
34
# File 'lib/flows/plugin/output_contract/errors.rb', line 26

def message
  shifted_error = @error.split("\n").map { |str| "  #{str}" }.join("\n")

  "Output contract for #{@klass} is violated.\n" \
  "Result:\n" \
  "  `#{@result.inspect}`\n" \
  "Contract Error:\n" \
  "#{shifted_error}"
end