Sha256: 32134f54b2b1349f33a67c23ad3050838e59499b01091c9b9497f52b115eb797

Contents?: true

Size: 460 Bytes

Versions: 4

Compression:

Stored size: 460 Bytes

Contents

require 'zendesk_api/error'

module ZendeskAPI
  module Middleware
    module Response
      class RaiseError < Faraday::Response::RaiseError
        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

4 entries across 4 versions & 1 rubygems

Version Path
zendesk_api-1.0.0 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-0.4.0.rc3 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-0.4.0.rc2 lib/zendesk_api/middleware/response/raise_error.rb
zendesk_api-0.4.0.rc1 lib/zendesk_api/middleware/response/raise_error.rb