module GitlabRuby

Constants

VERSION

Public Class Methods

check_response_status(resp) click to toggle source
# File lib/gitlab_ruby/api_errors.rb, line 6
def self.check_response_status(resp)
  if resp.body
    case resp.status
    when 400 then raise BadRequestError, format_error(resp)
    when 401 then raise UnauthorizedError, format_error(resp)
    when 403 then raise ForbiddenError, format_error(resp)
    when 404 then raise NotFoundError, format_error(resp)
    when 405 then raise MethodNotAllowedError, format_error(resp)
    when 409 then raise ConflictError, format_error(resp)
    when 422 then raise UnprocessableError, format_error(resp)
    when 500 then raise ServerError, format_error(resp)
    end
  end

  if resp.status > 400
    raise APIError, "[#{resp.status}] #{resp.body}"
  end
end
format_error(resp) click to toggle source
# File lib/gitlab_ruby/api_errors.rb, line 2
def self.format_error(resp)
  resp.body
end