lib/slack/web/faraday/response/raise_error.rb
# frozen_string_literal: true module Slack module Web module Faraday module Response class RaiseError < ::Faraday::Response::Middleware def on_complete(env) raise Slack::Web::Api::Errors::TooManyRequestsError, env.response if env.status == 429 return unless (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 end end end end