Module: GitlabRuby
- Defined in:
- lib/gitlab_ruby.rb,
lib/gitlab_ruby/client.rb,
lib/gitlab_ruby/errors.rb,
lib/gitlab_ruby/version.rb,
lib/gitlab_ruby/api_errors.rb,
lib/gitlab_ruby/api_object.rb,
lib/gitlab_ruby/query_chain.rb,
lib/gitlab_ruby/helpers/query_chain.rb
Defined Under Namespace
Modules: Helpers
Classes: APIError, APIObject, BadRequestError, Client, ConflictError, ForbiddenError, MethodNotAllowedError, NotFoundError, QueryChain, QueryChainArgumentError, ServerError, UnauthorizedError, UnprocessableError
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.check_response_status(resp) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 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
|
2
3
4
|
# File 'lib/gitlab_ruby/api_errors.rb', line 2
def self.format_error(resp)
resp.body
end
|