Sha256: d752b9531e40392cd21a326e15eab2582ca04794efe76a0e26c52a1cae6587ac

Contents?: true

Size: 818 Bytes

Versions: 9

Compression:

Stored size: 818 Bytes

Contents

# tested via spec/core/middleware/response/raise_error_spec.rb
module ZendeskAPI
  module Error
    class ClientError < Faraday::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

9 entries across 9 versions & 1 rubygems

Version Path
zendesk_api-1.31.0 lib/zendesk_api/error.rb
zendesk_api-1.30.0 lib/zendesk_api/error.rb
zendesk_api-1.29.0 lib/zendesk_api/error.rb
zendesk_api-1.28.0 lib/zendesk_api/error.rb
zendesk_api-1.27.0 lib/zendesk_api/error.rb
zendesk_api-1.26.0 lib/zendesk_api/error.rb
zendesk_api-1.25.0 lib/zendesk_api/error.rb
zendesk_api-1.24.0 lib/zendesk_api/error.rb
zendesk_api-1.23.0 lib/zendesk_api/error.rb