Sha256: 677a77055492b21dd3521d2f5b6399adb52ba8534722619c4c87259bdaa2b978

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-client-0.14.5 lib/slack/web/faraday/response/raise_error.rb