Exception: Bitly::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/bitly/error.rb

Overview

An error class that covers all potential errors from the Bitly API. In an error scenario, the API is only guaranteed to return a status_code and status_txt: dev.bitly.com/formats.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Creates a new Bitly::Error object

Parameters:



25
26
27
28
29
30
31
# File 'lib/bitly/error.rb', line 25

def initialize(response)
  @response = response
  @status_code = response.status
  @description = response.body["description"]
  @message = "[#{@status_code}] #{response.body["message"]}"
  super(@message)
end

Instance Attribute Details

#descriptionString (readonly)

Returns The description of the failed request.

Returns:

  • (String)

    The description of the failed request



15
16
17
# File 'lib/bitly/error.rb', line 15

def description
  @description
end

#responseBitly::HTTP::Response (readonly)

Returns The response that caused the error.

Returns:



19
20
21
# File 'lib/bitly/error.rb', line 19

def response
  @response
end

#status_codeString (readonly)

Returns The status code of the failed request.

Returns:

  • (String)

    The status code of the failed request



11
12
13
# File 'lib/bitly/error.rb', line 11

def status_code
  @status_code
end