Class: Open311::Response::RaiseError Private
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Open311::Response::RaiseError
- Defined in:
- lib/open311/response/raise_error.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #error_message(response) ⇒ Object private
-
#on_complete(response) ⇒ Object
private
rubocop:disable AbcSize, CyclomaticComplexity, MethodLength.
Instance Method Details
#error_message(response) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/open311/response/raise_error.rb', line 28 def (response) "#{response[:method].to_s.upcase} #{response[:url]}: #{response[:response_headers]['status']}#{(': ' + response[:body]['error']) if response[:body] && response[:body]['error']}" end |
#on_complete(response) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable AbcSize, CyclomaticComplexity, MethodLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/open311/response/raise_error.rb', line 7 def on_complete(response) # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength case response[:status].to_i when 400 fail Open311::BadRequest.new((response)) when 401 fail Open311::Unauthorized.new((response)) when 403 fail Open311::Forbidden.new((response)) when 404 fail Open311::NotFound.new((response)) when 406 fail Open311::NotAcceptable.new((response)) when 500 fail Open311::InternalServerError.new((response)) when 502 fail Open311::BadGateway.new((response)) when 503 fail Open311::ServiceUnavailable.new((response)) end end |