Class: Savon::HTTPError

Inherits:
Error
  • Object
show all
Defined in:
lib/savon/http_error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ HTTPError

Returns a new instance of HTTPError.



9
10
11
# File 'lib/savon/http_error.rb', line 9

def initialize(http)
  @http = http
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



13
14
15
# File 'lib/savon/http_error.rb', line 13

def http
  @http
end

Class Method Details

.present?(http) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/savon/http_error.rb', line 5

def self.present?(http)
  http.error?
end

Instance Method Details

#to_hashObject



21
22
23
# File 'lib/savon/http_error.rb', line 21

def to_hash
  { code: @http.code, headers: @http.headers, body: @http.body }
end

#to_sObject



15
16
17
18
19
# File 'lib/savon/http_error.rb', line 15

def to_s
  String.new("HTTP error (#{@http.code})").tap do |str_error|
    str_error << ": #{@http.body}" unless @http.body.empty?
  end
end