Sha256: de5df7bca0744610a7f5771298df5b7e9e24f7721e7b67bfa2e8f2bc8c378121

Contents?: true

Size: 629 Bytes

Versions: 12

Compression:

Stored size: 629 Bytes

Contents

# frozen_string_literal: true
module Notion
  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 Notion::Api::Errors::UnavailableError.new('unavailable_error', env.response)
        end

        def call(env)
          super
        rescue ::Faraday::TimeoutError, ::Faraday::ConnectionFailed
          raise Notion::Api::Errors::TimeoutError.new('timeout_error', env.response)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
notion-ruby-client-1.0.0 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-1.0.0.pre.beta2 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-1.0.0.pre.beta1 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.1.0.pre.beta1 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.8 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.7 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.6 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.5 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.4 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.3 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.2 lib/notion/faraday/response/wrap_error.rb
notion-ruby-client-0.0.1 lib/notion/faraday/response/wrap_error.rb