Sha256: 0849d36ed43bb13e96290448ec64602ee206a45789678ad4509f5e3f6dd38b01

Contents?: true

Size: 825 Bytes

Versions: 5

Compression:

Stored size: 825 Bytes

Contents

# tested via spec/core/middleware/response/raise_error_spec.rb
module ZendeskAPI
  module Error
    class ClientError < Faraday::Error::ClientError
      attr_reader :wrapped_exception

      def to_s
        if response
          "#{super} -- #{response.method} #{response.url}"
        else
          super
        end
      end
    end

    class RecordInvalid < ClientError
      attr_accessor :errors

      def initialize(*)
        super

        if response[:body].is_a?(Hash)
          @errors = response[:body]["details"] || response[:body]["description"]
        end

        @errors ||= {}
      end

      def to_s
        "#{self.class.name}: #{@errors}"
      end
    end

    class NetworkError < ClientError; end
    class RecordNotFound < ClientError; end
    class RateLimited < ClientError; end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zendesk_api-1.22.0 lib/zendesk_api/error.rb
zendesk_api-1.21.0 lib/zendesk_api/error.rb
zendesk_api-1.20.0 lib/zendesk_api/error.rb
zendesk_api-1.19.1 lib/zendesk_api/error.rb
zendesk_api-1.19.0 lib/zendesk_api/error.rb