Class: PexelsApiClient::Base
- Inherits:
-
Flexirest::Base
- Object
- Flexirest::Base
- PexelsApiClient::Base
- Defined in:
- lib/pexels_api_client/base.rb
Instance Method Summary collapse
Instance Method Details
#rescue_errors(_name, response) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pexels_api_client/base.rb', line 9 def rescue_errors(_name, response) if (400..499).cover?(response.status) result = JSON.parse(response.body) = result['errors'] || [result['error']] raise BadRequestError, .to_a.join(', ') elsif (500..599).cover?(response.status) raise ServerError, "Could not process your request: status #{response.status}" end end |