Sha256: 72d31b25adf23079738cd3a4e908356c0ed86bc929fe2322e495471f23e4d3b5

Contents?: true

Size: 638 Bytes

Versions: 11

Compression:

Stored size: 638 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)
        end

        def on_complete(env)
          case env[:status]
          when 404
            raise Error::RecordNotFound.new(env)
          when 422
            raise Error::RecordInvalid.new(env)
          when 400...600
            raise Error::NetworkError.new(env)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zendesk_api-1.1.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.1.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.1.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.1.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.7 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.6 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.5 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.0.1 lib/zendesk_api/middleware/response/raise_error.rb