Module: Uploadcare::Internal::ErrorHandler
- Included in:
- Api::Rest, Api::Upload
- Defined in:
- lib/uploadcare/internal/error_handler.rb
Overview
Handles API errors and converts them to appropriate exceptions.
This module is included in API base classes to provide consistent error handling across all API requests. It parses error responses and raises typed exceptions.
Instance Method Summary collapse
-
#handle_error(error) ⇒ Object
Handle a failed API request and raise an appropriate exception.
Instance Method Details
#handle_error(error) ⇒ Object
Handle a failed API request and raise an appropriate exception.
Parses the error response and raises a typed exception based on the HTTP status code. Also handles Upload API errors which return status 200 with error details in the body.
24 25 26 27 28 29 30 31 32 |
# File 'lib/uploadcare/internal/error_handler.rb', line 24 def handle_error(error) response = error.response return raise Uploadcare::Exception::RequestError, error. if response.nil? catch_upload_errors(response) = (response) raise_status_error(response, ) end |