Sha256: b48da146643676d077de6f29807658abf1a272688060ae85746c705bf9e426ff

Contents?: true

Size: 632 Bytes

Versions: 6

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true
module Slack
  module Web
    module Faraday
      module Response
        class WrapError < ::Faraday::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

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-client-2.4.0 lib/slack/web/faraday/response/wrap_error.rb
slack-ruby-client-2.3.0 lib/slack/web/faraday/response/wrap_error.rb
slack-ruby-client-2.2.0 lib/slack/web/faraday/response/wrap_error.rb
slack-ruby-client-2.1.0 lib/slack/web/faraday/response/wrap_error.rb
slack-ruby-client-2.0.0 lib/slack/web/faraday/response/wrap_error.rb
slack-ruby-client-1.1.0 lib/slack/web/faraday/response/wrap_error.rb