Sha256: bada7033da4ef73442338caebc14dde2f939299c66581605e5b26f8bd72efa2f

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

# encoding: utf-8
module Inforouter #:nodoc:
  module Errors #:nodoc:
    # This error is raised when a SOAP call fails.
    class SOAPError < InforouterError
      # Original SOAP fault.
      attr_reader :fault

      def initialize(e)
        @fault = e
        e.to_hash.tap do |fault|
          fault_code = fault[:fault][:faultcode]
          fault_string = parse_fault(fault[:fault][:faultstring])
          super(compose_message('soap_error',
                                :message => fault_string,
                                :code => fault_code
          ))
        end
      end

      private

      # @param fault_string [String]
      #
      # @return [String]
      def parse_fault(fault_string)
        fault_string.lines.first.strip
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inforouter-0.2.0 lib/inforouter/errors/soap_error.rb