Exception: Gitlab::Error::ResponseError
- Defined in:
- lib/gitlab/error.rb
Overview
Custom error class for rescuing from HTTP response errors.
Direct Known Subclasses
BadGateway, BadRequest, Conflict, Forbidden, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, Unprocessable
Constant Summary collapse
- POSSIBLE_MESSAGE_KEYS =
i[ error_description error].freeze
Instance Method Summary collapse
-
#initialize(response) ⇒ ResponseError
constructor
A new instance of ResponseError.
-
#response_message ⇒ String
Body content returned in the HTTP response.
-
#response_status ⇒ Integer
Status code returned in the HTTP response.
Constructor Details
#initialize(response) ⇒ ResponseError
Returns a new instance of ResponseError.
18 19 20 21 |
# File 'lib/gitlab/error.rb', line 18 def initialize(response) @response = response super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
82 83 84 85 86 87 88 |
# File 'lib/gitlab/error.rb', line 82 def method_missing(method, *args, &block) if @response.parsed_response.key?(method) @response.parsed_response[method] else super end end |
Instance Method Details
#response_message ⇒ String
Body content returned in the HTTP response
33 34 35 |
# File 'lib/gitlab/error.rb', line 33 def @response.parsed_response. end |
#response_status ⇒ Integer
Status code returned in the HTTP response.
26 27 28 |
# File 'lib/gitlab/error.rb', line 26 def response_status @response.code end |