Exception: Puppet::Forge::Errors::ResponseError
- Inherits:
-
ForgeError
- Object
- RuntimeError
- Error
- ForgeError
- Puppet::Forge::Errors::ResponseError
- Defined in:
- lib/puppet/forge/errors.rb
Overview
This exception is raised when there is a bad HTTP response from the forge and optionally a message in the response.
Instance Attribute Summary
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(options) ⇒ ResponseError
constructor
A new instance of ResponseError.
-
#multiline ⇒ String
Return a multiline version of the error message.
Constructor Details
#initialize(options) ⇒ ResponseError
Returns a new instance of ResponseError.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/puppet/forge/errors.rb', line 78 def initialize() @uri = [:uri] @message = [:message] response = [:response] @response = "#{response.code} #{response..strip}" begin body = JSON.parse(response.body) if body['message'] @message ||= body['message'].strip end rescue JSON::ParserError end = _("Request to Puppet Forge failed. Detail: ") << @message << " / " if @message << @response << "." super(, original) end |
Instance Method Details
#multiline ⇒ String
Return a multiline version of the error message
101 102 103 104 105 106 107 108 109 |
# File 'lib/puppet/forge/errors.rb', line 101 def multiline = _(<<-EOS).chomp % { uri: @uri, response: @response } Request to Puppet Forge failed. The server being queried was %{uri} The HTTP response we received was '%{response}' EOS << _("\n The message we received said '%{message}'") % { message: @message } if @message end |