Exception: Gitlab::Error::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/gitlab/error.rb

Overview

Custom error class for rescuing from HTTP response errors.

Constant Summary collapse

POSSIBLE_MESSAGE_KEYS =
%i[message error_description error].freeze

Instance Method Summary collapse

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(build_error_message)
end

Instance Method Details

#error_codeString

Additional error context returned by some API endpoints

Returns:

  • (String)


40
41
42
43
44
45
46
# File 'lib/gitlab/error.rb', line 40

def error_code
  if @response.respond_to?(:error_code)
    @response.error_code
  else
    ''
  end
end

#response_messageString

Body content returned in the HTTP response

Returns:

  • (String)


33
34
35
# File 'lib/gitlab/error.rb', line 33

def response_message
  @response.parsed_response.message
end

#response_statusInteger

Status code returned in the HTTP response.

Returns:

  • (Integer)


26
27
28
# File 'lib/gitlab/error.rb', line 26

def response_status
  @response.code
end