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



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

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