Sha256: ab267ce73ac11821591cddad27270fc76f0033d4a3aac3d6b3a008b0dbcfce19

Contents?: true

Size: 935 Bytes

Versions: 32

Compression:

Stored size: 935 Bytes

Contents

require "savon/error"
require "savon/soap/xml"

module Savon
  module HTTP

    # = Savon::HTTP::Error
    #
    # Represents an HTTP error. Contains the original <tt>HTTPI::Response</tt>.
    class Error < Error

      # Expects an <tt>HTTPI::Response</tt>.
      def initialize(http)
        self.http = http
      end

      # Accessor for the <tt>HTTPI::Response</tt>.
      attr_accessor :http

      # Returns whether an HTTP error is present.
      def present?
        http.error?
      end

      # Returns the HTTP error message.
      def to_s
        return "" unless present?
        
        @message ||= begin
          message = "HTTP error (#{http.code})"
          message << ": #{http.body}" unless http.body.empty?
        end
      end

      # Returns the HTTP response as a Hash.
      def to_hash
        @hash = { :code => http.code, :headers => http.headers, :body => http.body }
      end

    end
  end
end

Version data entries

32 entries across 32 versions & 6 rubygems

Version Path
savon-0.9.0 lib/savon/http/error.rb
savon-0.8.6 lib/savon/http/error.rb
savon-0.8.5 lib/savon/http/error.rb
savon-0.8.4 lib/savon/http/error.rb
savon-0.8.3 lib/savon/http/error.rb
savon-0.8.2 lib/savon/http/error.rb
savon-0.8.1 lib/savon/http/error.rb
savon-0.8.0 lib/savon/http/error.rb
savon-0.8.0.beta.4 lib/savon/http/error.rb
savon-0.8.0.beta.3 lib/savon/http/error.rb
savon-0.8.0.beta.2 lib/savon/http/error.rb
savon-0.8.0.beta.1 lib/savon/http/error.rb