Exception: Savon::HTTP::Error
- Defined in:
- lib/savon/http/error.rb
Overview
Savon::HTTP::Error
Represents an HTTP error. Contains the original HTTPI::Response
.
Instance Attribute Summary collapse
-
#http ⇒ Object
Accessor for the
HTTPI::Response
.
Instance Method Summary collapse
-
#initialize(http) ⇒ Error
constructor
Expects an
HTTPI::Response
. -
#present? ⇒ Boolean
Returns whether an HTTP error is present.
-
#to_hash ⇒ Object
Returns the HTTP response as a Hash.
-
#to_s ⇒ Object
Returns the HTTP error message.
Constructor Details
#initialize(http) ⇒ Error
Expects an HTTPI::Response
.
13 14 15 |
# File 'lib/savon/http/error.rb', line 13 def initialize(http) self.http = http end |
Instance Attribute Details
#http ⇒ Object
Accessor for the HTTPI::Response
.
18 19 20 |
# File 'lib/savon/http/error.rb', line 18 def http @http end |
Instance Method Details
#present? ⇒ Boolean
Returns whether an HTTP error is present.
21 22 23 |
# File 'lib/savon/http/error.rb', line 21 def present? http.error? end |
#to_hash ⇒ Object
Returns the HTTP response as a Hash.
36 37 38 |
# File 'lib/savon/http/error.rb', line 36 def to_hash @hash = { :code => http.code, :headers => http.headers, :body => http.body } end |
#to_s ⇒ Object
Returns the HTTP error message.
26 27 28 29 30 31 32 33 |
# File 'lib/savon/http/error.rb', line 26 def to_s return "" unless present? @message ||= begin = "HTTP error (#{http.code})" << ": #{http.body}" unless http.body.empty? end end |