Exception: PuppetForge::ErrorWithDetail

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

Direct Known Subclasses

ReleaseBadContent, ReleaseForbidden

Instance Attribute Summary

Attributes inherited from Error

#original

Class Method Summary collapse

Methods inherited from Error

#initialize

Constructor Details

This class inherits a constructor from PuppetForge::Error

Class Method Details

.from_response(response) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet_forge/error.rb', line 33

def self.from_response(response)
  body = JSON.parse(response[:body])

  message = body['message']
  if body.key?('errors') && !body['errors']&.empty?
    message << "\nThe following errors were returned from the server:\n - #{body['errors'].join("\n - ")}"
  end

  new(message)
end