Exception: Contentful::Management::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Contentful::Management::Error
- Defined in:
- lib/contentful/management/error.rb
Overview
All errors raised by the contentful gem are either instances of Contentful::Management::Error or inherit from Contentful::Management::Error
Direct Known Subclasses
AccessDenied, BadGateway, BadRequest, Conflict, NotFound, RateLimitExceeded, ServerError, ServiceUnavailable, Unauthorized, UnparsableJson, UnparsableResource, UnprocessableEntity
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#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::Management::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.
10 11 12 13 14 15 16 17 18 |
# File 'lib/contentful/management/error.rb', line 10 def initialize(response) @response = response @error = { url: response.request.endpoint, message: response., details: response.raw.body.instance_variable_get(:@contents) } super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/contentful/management/error.rb', line 8 def error @error end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/contentful/management/error.rb', line 8 def response @response end |
Class Method Details
.[](error_status_code) ⇒ Object
Shortcut for creating specialized error classes USAGE rescue Contentful::Management::Error
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/contentful/management/error.rb', line 22 def self.[](error_status_code) errors = { 400 => BadRequest, 401 => Unauthorized, 403 => AccessDenied, 404 => NotFound, 409 => Conflict, 422 => UnprocessableEntity, 429 => RateLimitExceeded, 500 => ServerError, 502 => BadGateway, 503 => ServiceUnavailable }.freeze errors.key?(error_status_code) ? errors[error_status_code] : Error end |