lib/slack/web/faraday/response/wrap_error.rb in slack-ruby-client-0.16.0 vs lib/slack/web/faraday/response/wrap_error.rb in slack-ruby-client-0.17.0
- old
+ new
@@ -1,16 +1,22 @@
# frozen_string_literal: true
module Slack
module Web
module Faraday
module Response
- class WrapError < ::Faraday::Response::RaiseError
+ class WrapError < ::Faraday::Response::Middleware
+ UNAVAILABLE_ERROR_STATUSES = (500..599).freeze
+
def on_complete(env)
- super
- rescue Slack::Web::Api::Errors::SlackError
- raise
- rescue ::Faraday::ServerError
+ return unless UNAVAILABLE_ERROR_STATUSES.cover?(env.status)
+
raise Slack::Web::Api::Errors::UnavailableError.new('unavailable_error', env.response)
+ end
+
+ def call(env)
+ super
+ rescue ::Faraday::TimeoutError, ::Faraday::ConnectionFailed
+ raise Slack::Web::Api::Errors::TimeoutError.new('timeout_error', env.response)
end
end
end
end
end