Class: Github::Response::RaiseError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if status code requires raising a ServiceError

Raises:

  • (error_class)

11
12
13
14
15
16
17
18
19
# File 'lib/github_api/response/raise_error.rb', line 11

def on_complete(env)
  status_code   = env[:status].to_i
  service_error = Github::Error::ServiceError
  error_class = service_error.error_mapping[status_code]
  if !error_class and (400...600) === status_code
    error_class = service_error
  end
  raise error_class.new(env) if error_class
end