Sha256: f936ba9543e28491ea400296ca066b6dc6b26c5cc9fb0fbf51b41af166dfb13b

Contents?: true

Size: 880 Bytes

Versions: 28

Compression:

Stored size: 880 Bytes

Contents

module Spreedly
  class Error < StandardError
  end

  class XmlErrorsList < Error
    attr_reader :errors
    include ErrorsParser

    def initialize(xml_doc)
      @errors = errors_from(xml_doc)
    end

    def message
      @errors.map { |each| each[:message] }.join("\n")
    end
  end

  class AuthenticationError < XmlErrorsList
  end

  class NotFoundError < XmlErrorsList
  end

  class TransactionCreationError < XmlErrorsList
  end

  class PaymentRequiredError < XmlErrorsList
  end

  class TimeoutError < Error
    def initialize(message = "The payment system is not responding.")
      super
    end
  end

  class UnexpectedResponseError < Error
    attr_reader :response

    def initialize(response)
      @response = response
    end

    def to_s
      "Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
    end
  end

end


Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
spreedly-2.0.28 lib/spreedly/error.rb
spreedly-2.0.27 lib/spreedly/error.rb
spreedly-2.0.26 lib/spreedly/error.rb
spreedly-2.0.25 lib/spreedly/error.rb
spreedly-2.0.24 lib/spreedly/error.rb
spreedly-2.0.23 lib/spreedly/error.rb
spreedly-2.0.22 lib/spreedly/error.rb
spreedly-2.0.21 lib/spreedly/error.rb
spreedly-2.0.20 lib/spreedly/error.rb
spreedly-2.0.19 lib/spreedly/error.rb
spreedly-2.0.18 lib/spreedly/error.rb
spreedly-2.0.17 lib/spreedly/error.rb
spreedly-2.0.16 lib/spreedly/error.rb
spreedly-2.0.15 lib/spreedly/error.rb
spreedly-2.0.14 lib/spreedly/error.rb
spreedly-2.0.13 lib/spreedly/error.rb
spreedly-2.0.11 lib/spreedly/error.rb
spreedly-2.0.10 lib/spreedly/error.rb
spreedly-2.0.9 lib/spreedly/error.rb
spreedly-2.0.8 lib/spreedly/error.rb