Sha256: 590b96234706b9ad13ad2e7bb0b0248a6944b54d35cd8ac6feb57bccc4abd0b3

Contents?: true

Size: 676 Bytes

Versions: 15

Compression:

Stored size: 676 Bytes

Contents

require 'zendesk_api/error'

module ZendeskAPI
  module Middleware
    module Response
      class RaiseError < Faraday::Response::RaiseError
        def call(env)
          super
        rescue Faraday::Error::TimeoutError, Faraday::Error::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

15 entries across 15 versions & 1 rubygems

Version Path
zendesk_api-1.24.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.23.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.22.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.21.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.20.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.19.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.19.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.18.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.17.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.16.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.15.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.14.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.14.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.14.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.14.0 lib/zendesk_api/middleware/response/raise_error.rb