Exception: Greeve::ResponseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/greeve/response_error.rb

Overview

HTTP response failed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ResponseError

Returns a new instance of ResponseError.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :code (Integer)

    HTTP error code

  • :status_message (String)

    HTTP error message



11
12
13
14
# File 'lib/greeve/response_error.rb', line 11

def initialize(opts = {})
  @code = opts.fetch(:code).to_i
  @status_message = opts.fetch(:status_message).dup.freeze
end

Instance Attribute Details

#codeObject (readonly)

HTTP error code



5
6
7
# File 'lib/greeve/response_error.rb', line 5

def code
  @code
end

#status_messageObject (readonly)

HTTP error message



7
8
9
# File 'lib/greeve/response_error.rb', line 7

def status_message
  @status_message
end

Instance Method Details

#messageString

Returns exception error message.

Returns:

  • (String)

    exception error message



17
18
19
# File 'lib/greeve/response_error.rb', line 17

def message
  "#{@code} #{@status_message}"
end