Class: Slack::Web::Faraday::Response::WrapError

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

Constant Summary collapse

UNAVAILABLE_ERROR_STATUSES =
(500..599).freeze

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
# File 'lib/slack/web/faraday/response/wrap_error.rb', line 15

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

#on_complete(env) ⇒ Object



9
10
11
12
13
# File 'lib/slack/web/faraday/response/wrap_error.rb', line 9

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

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