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
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/savon-0.9.5/lib/savon/http/error.rb
savon-1.1.0 lib/savon/http/error.rb
savon-1.0.0 lib/savon/http/error.rb
savon-0.9.14 lib/savon/http/error.rb
savon-0.9.11 lib/savon/http/error.rb
savon-0.9.10 lib/savon/http/error.rb
savon-0.9.9 lib/savon/http/error.rb
savon-0.9.8 lib/savon/http/error.rb
they-savon-0.9.7.1 lib/savon/http/error.rb
regenersis-savon-1.0.0 lib/savon/http/error.rb
they-savon-0.9.7 lib/savon/http/error.rb
savon-0.9.7 lib/savon/http/error.rb
savon-0.9.6 lib/savon/http/error.rb
savon-0.9.5 lib/savon/http/error.rb
savon-0.9.4 lib/savon/http/error.rb
savon-0.9.3 lib/savon/http/error.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/savon-0.9.2/lib/savon/http/error.rb
savon-0.9.2 lib/savon/http/error.rb
s-savon-0.8.6 lib/savon/http/error.rb
savon-0.9.1 lib/savon/http/error.rb