Class: BitBucket::Response::RaiseError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/bitbucket_rest_api/response/raise_error.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bitbucket_rest_api/response/raise_error.rb', line 9

def on_complete(env)
  case env[:status].to_i
  when 400
    raise BitBucket::Error::BadRequest.new(env)
  when 401
    raise BitBucket::Error::Unauthorized.new(env)
  when 403
    raise BitBucket::Error::Forbidden.new(env)
  when 404
    raise BitBucket::Error::NotFound.new(env)
  when 422
    raise BitBucket::Error::UnprocessableEntity.new(env)
  when 500
    raise BitBucket::Error::InternalServerError.new(env)
  when 503
    raise BitBucket::Error::ServiceUnavailable.new(env)
  when 400...600
    raise BitBucket::Error::ServiceError.new(env)
  end
end