Class: Ashikawa::Core::ErrorResponse
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Ashikawa::Core::ErrorResponse
- Defined in:
- lib/ashikawa-core/error_response.rb
Overview
A response from the server
Constant Summary collapse
- BadSyntaxStatus =
Status code for a [Bad Request](httpstatus.es/400)
400
- AuthenticationFailed =
Status code for an [Unauthorized Request](httpstatus.es/401)
401
- ResourceNotFoundError =
Status code for a [Not Found Resource](httpstatus.es/404)
404
- ClientErrorStatuses =
All other status codes for client errors
405...499
- ServerErrorStatuses =
All status codes for server errors
500...599
Instance Method Summary collapse
-
#on_complete(env) ⇒ Object
On completion of the request raise errors depending on the status.
Instance Method Details
#on_complete(env) ⇒ Object
On completion of the request raise errors depending on the status
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ashikawa-core/error_response.rb', line 45 def on_complete(env) @body = env[:body] || {} @url = env[:url] case env[:status] when BadSyntaxStatus then bad_syntax when AuthenticationFailed then authentication_failed when ResourceNotFoundError then resource_not_found when ClientErrorStatuses then client_error when ServerErrorStatuses then server_error end end |