Sha256: a90655121f51274977a0eac0306c0089dffb3dbb19efb139e564e43749e2f3de

Contents?: true

Size: 677 Bytes

Versions: 23

Compression:

Stored size: 677 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

23 entries across 23 versions & 1 rubygems

Version Path
zendesk_api-1.13.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.13.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.13.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.13.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.12.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.12.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.7 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.6 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.5 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.11.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.10.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.9.6 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.9.5 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.9.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.9.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.9.2 lib/zendesk_api/middleware/response/raise_error.rb