Sha256: 7c9b824338ee5d79ceb58b24c467a27f1294321456244606bf6aaaa4d9b7c3c5

Contents?: true

Size: 648 Bytes

Versions: 6

Compression:

Stored size: 648 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 400...600
            raise Error::NetworkError.new(env)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zendesk_api-1.7.4 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.7.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.7.1 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.7.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.6.3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-1.6.2 lib/zendesk_api/middleware/response/raise_error.rb