Exception: Kontena::Errors::StandardErrorHash

Inherits:
StandardError
  • Object
show all
Defined in:
lib/kontena/errors.rb

Overview

The normal {foo: “invalid foo”} error response format used by the API

Instance Attribute Summary collapse

Attributes inherited from StandardError

#status

Instance Method Summary collapse

Constructor Details

#initialize(status, message, errors) ⇒ StandardErrorHash

Returns a new instance of StandardErrorHash.

Parameters:

  • errors (Hash)


20
21
22
23
# File 'lib/kontena/errors.rb', line 20

def initialize(status, message, errors)
  super(status, message)
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



17
18
19
# File 'lib/kontena/errors.rb', line 17

def errors
  @errors
end

Instance Method Details

#errors_message(indent: "\t") ⇒ Object

Render as indented YAML



26
27
28
29
# File 'lib/kontena/errors.rb', line 26

def errors_message(indent: "\t")
  require 'yaml'
  @errors.to_yaml.lines[1..-1].map{|line| "#{indent}#{line}" }.join
end

#messageObject

Render the full multi-line message including YAML-formatted errors



32
33
34
# File 'lib/kontena/errors.rb', line 32

def message
  "#{super}:\n#{errors_message}"
end