Exception: Bitly::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Bitly::Error
- 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
-
#description ⇒ String
readonly
The description of the failed request.
-
#response ⇒ Bitly::HTTP::Response
readonly
The response that caused the error.
-
#status_code ⇒ String
readonly
The status code of the failed request.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
Creates a new Bitly::Error object.
Constructor Details
#initialize(response) ⇒ Error
Creates a new Bitly::Error object
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
#description ⇒ String (readonly)
Returns The description of the failed request.
15 16 17 |
# File 'lib/bitly/error.rb', line 15 def description @description end |
#response ⇒ Bitly::HTTP::Response (readonly)
Returns The response that caused the error.
19 20 21 |
# File 'lib/bitly/error.rb', line 19 def response @response end |
#status_code ⇒ String (readonly)
Returns The status code of the failed request.
11 12 13 |
# File 'lib/bitly/error.rb', line 11 def status_code @status_code end |