Exception: Puppet::Forge::Errors::ResponseError Private
- Inherits:
-
ForgeError
- Object
- RuntimeError
- Error
- ForgeError
- Puppet::Forge::Errors::ResponseError
- Defined in:
- lib/puppet/forge/errors.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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
private
A new instance of ResponseError.
-
#multiline ⇒ String
private
Return a multiline version of the error message.
Constructor Details
#initialize(options) ⇒ ResponseError
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ResponseError.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/puppet/forge/errors.rb', line 79 def initialize() @uri = [:uri] @message = [:message] response = [:response] @response = "#{response.code} #{response.reason.strip}" begin body = Puppet::Util::Json.load(response.body) if body['message'] @message ||= body['message'].strip end rescue Puppet::Util::Json::ParseError end = if @message _("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: "#{@message} / #{@response}" } else _("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: @response } end super(, original) end |
Instance Method Details
#multiline ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a multiline version of the error message
104 105 106 107 108 109 110 111 |
# File 'lib/puppet/forge/errors.rb', line 104 def multiline = [] << _('Request to Puppet Forge failed.') << _(' The server being queried was %{uri}') % { uri: @uri } << _(" The HTTP response we received was '%{response}'") % { response: @response } << _(" The message we received said '%{message}'") % { message: @message } if @message .join("\n") end |