Exception: Puppet::Forge::Errors::ResponseError

Inherits:
ForgeError show all
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

#original

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ResponseError

Returns a new instance of ResponseError.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :uri (String)

    The URI that failed

  • :input (String)

    The user’s input (e.g. module name)

  • :message (String)

    Error from the API response (optional)

  • :response (Net::HTTPResponse)

    The original HTTP response



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/puppet/forge/errors.rb', line 76

def initialize(options)
  @uri     = options[:uri]
  @input   = options[:input]
  @message = options[:message]
  response = options[:response]
  @response = "#{response.code} #{response.message.strip}"

  message = "Could not execute operation for '#{@input}'. Detail: "
  message << @message << " / " if @message
  message << @response << "."
  super(message, original)
end

Instance Method Details

#multilineString

Return a multiline version of the error message

Returns:

  • (String)

    the multiline version of the error message



92
93
94
95
96
97
98
99
100
# File 'lib/puppet/forge/errors.rb', line 92

def multiline
  message = "Could not execute operation for '\#{@input}'\n  The server being queried was \#{@uri}\n  The HTTP response we received was '\#{@response}'\n  EOS\n  message << \"  The message we received said '\#{@message}'\\n\" if @message\n  message << \"    Check the author and module names are correct.\"\nend\n"