Sha256: 9878ad20de8ba91f7806313ab4f97fc79f0174a5dd456296b93483b1b7baf4d5

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true
module Slack
  module Web
    module Faraday
      module Response
        class WrapError < ::Faraday::Response::Middleware
          UNAVAILABLE_ERROR_STATUSES = (500..599).freeze

          def on_complete(env)
            return unless UNAVAILABLE_ERROR_STATUSES.cover?(env.status)

            raise Slack::Web::Api::Errors::UnavailableError, env.response
          end

          def call(env)
            super
          rescue ::Faraday::TimeoutError, ::Faraday::ConnectionFailed
            raise Slack::Web::Api::Errors::TimeoutError, env.response
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-client-1.0.0 lib/slack/web/faraday/response/wrap_error.rb