Sha256: d6bca2a240bced0def5544b30d2942dd9157ddf63a687a1fbe486178c8869c83

Contents?: true

Size: 779 Bytes

Versions: 5

Compression:

Stored size: 779 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

5 entries across 5 versions & 1 rubygems

Version Path
inforouter-0.3.0 lib/inforouter/errors/soap_error.rb
inforouter-0.2.9 lib/inforouter/errors/soap_error.rb
inforouter-0.2.8 lib/inforouter/errors/soap_error.rb
inforouter-0.2.7 lib/inforouter/errors/soap_error.rb
inforouter-0.2.6 lib/inforouter/errors/soap_error.rb