Exception: Flows::Plugin::OutputContract::StatusError

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

Overview

Raised when no contract found for result

Since:

  • 0.4.0

Instance Method Summary collapse

Constructor Details

#initialize(klass, result, allowed_statuses) ⇒ StatusError

Returns a new instance of StatusError.

Since:

  • 0.4.0



39
40
41
42
43
# File 'lib/flows/plugin/output_contract/errors.rb', line 39

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

Instance Method Details

#messageObject

Since:

  • 0.4.0



45
46
47
48
49
50
51
52
53
54
# File 'lib/flows/plugin/output_contract/errors.rb', line 45

def message
  allowed_statuses_str = @allowed_statuses.map { |st| "`#{st.inspect}`" }.join(', ')

  "Output contract for #{@klass} is violated.\n" \
  "Result:\n" \
  "  `#{@result.inspect}`\n" \
  "Contract Error:\n" \
  "  has unexpected status `#{@result.status.inspect}`\n" \
  "  allowed statuses for `#{@result.class}` are: #{allowed_statuses_str}"
end