Exception: Contentful::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Contentful::Error
- Defined in:
- lib/contentful/error.rb
Overview
All errors raised by the contentful gem are either instances of Contentful::Error or inherit from Contentful::Error
Direct Known Subclasses
AccessDenied, BadGateway, BadRequest, NotFound, RateLimitExceeded, ServerError, ServiceUnavailable, Unauthorized, UnparsableJson
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
-
.[](error_status_code) ⇒ Object
Shortcut for creating specialized error classes USAGE rescue Contentful::Error.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
7 8 9 10 |
# File 'lib/contentful/error.rb', line 7 def initialize(response) @response = response super end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/contentful/error.rb', line 5 def response @response end |
Class Method Details
.[](error_status_code) ⇒ Object
Shortcut for creating specialized error classes USAGE rescue Contentful::Error
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/contentful/error.rb', line 14 def self.[](error_status_code) errors = { 400 => BadRequest, 401 => Unauthorized, 403 => AccessDenied, 404 => NotFound, 429 => RateLimitExceeded, 500 => ServerError, 502 => BadGateway, 503 => ServiceUnavailable } errors.key?(error_status_code) ? errors[error_status_code] : Error end |