Class: Slack::Web::Faraday::Response::RaiseError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object


6
7
8
9
10
11
12
13
# File 'lib/slack/web/faraday/response/raise_error.rb', line 6

def on_complete(env)
  if env.status == 429
    raise Slack::Web::Api::Errors::TooManyRequestsError, env.response
  elsif (body = env.body) && !body['ok']
    error_message = body['error'] || body['errors'].map { |message| message['error'] }.join(',')
    raise Slack::Web::Api::Errors::SlackError.new(error_message, env.response)
  end
end