Sha256: bd41bc46a30d0a3817ece639766c5d8aa15d7efbd9b07492253d5c5ea8ccb722

Contents?: true

Size: 662 Bytes

Versions: 27

Compression:

Stored size: 662 Bytes

Contents

require 'zendesk_api/error'

module ZendeskAPI
  module Middleware
    module Response
      class RaiseError < Faraday::Response::RaiseError
        def call(env)
          super
        rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
          raise Error::NetworkError.new(e, env)
        end

        def on_complete(env)
          case env[:status]
          when 404
            raise Error::RecordNotFound.new(env)
          when 422, 413
            raise Error::RecordInvalid.new(env)
          when 100..199, 400..599, 300..303, 305..399
            raise Error::NetworkError.new(env)
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
zendesk_api-3.1.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.1.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.5 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-3.0.0.rc1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-2.0.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-2.0.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.38.0.rc2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.38.0.rc1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.37.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.36.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.35.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.34.0 lib/zendesk_api/middleware/response/raise_error.rb
discourse_zendesk_api-1.0.1 lib/zendesk_api/middleware/response/raise_error.rb
discourse_zendesk_api-1.0.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.33.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.32.0 lib/zendesk_api/middleware/response/raise_error.rb