Exception: Apia::ManifestError

Inherits:
StandardError show all
Defined in:
lib/apia/errors/manifest_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ ManifestError

Returns a new instance of ManifestError.



8
9
10
# File 'lib/apia/errors/manifest_error.rb', line 8

def initialize(errors)
  @errors = errors
end

Instance Method Details

#detailObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/apia/errors/manifest_error.rb', line 24

def detail
  @errors.errors.map do |object, errors|
    {
      object: object.id,
      errors: errors.map do |error|
        {
          code: error[:code],
          description: error[:message]
        }
      end
    }
  end
end

#errorsObject



16
17
18
19
20
21
22
# File 'lib/apia/errors/manifest_error.rb', line 16

def errors
  @errors.errors.each_with_object([]) do |(object, errors), array|
    errors.each do |error|
      array << "#{object.id}: #{error[:code]} (#{error[:message]})"
    end
  end.join(', ')
end

#to_sObject



12
13
14
# File 'lib/apia/errors/manifest_error.rb', line 12

def to_s
  "#{@errors.errors.size} object(s) have issues that need attention (#{errors})"
end

#tripletObject



38
39
40
# File 'lib/apia/errors/manifest_error.rb', line 38

def triplet
  Rack.error_triplet('manifest_error', description: 'An issue exists with the API manifest that needs resolving by the developer.', detail: detail)
end