class GoogleAdsSavon::HTTP::Error

GoogleAdsSavon::HTTP::Error

Represents an HTTP error. Contains the original HTTPI::Response.

Attributes

http[RW]

Accessor for the HTTPI::Response.

Public Class Methods

new(http) click to toggle source

Expects an HTTPI::Response.

# File lib/ads_savon/http/error.rb, line 13
def initialize(http)
  self.http = http
end

Public Instance Methods

present?() click to toggle source

Returns whether an HTTP error is present.

# File lib/ads_savon/http/error.rb, line 21
def present?
  http.error?
end
to_hash() click to toggle source

Returns the HTTP response as a Hash.

# File lib/ads_savon/http/error.rb, line 36
def to_hash
  @hash = { :code => http.code, :headers => http.headers, :body => http.body }
end
to_s() click to toggle source

Returns the HTTP error message.

# File lib/ads_savon/http/error.rb, line 26
def to_s
  return "" unless present?

  @message ||= begin
    message = "HTTP error (#{http.code})"
    message << ": #{http.body}" unless http.body.empty?
  end
end