Exception: Iconoclasm::HTTPError

Inherits:
Error
  • Object
show all
Defined in:
lib/iconoclasm/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, response) ⇒ HTTPError

Returns a new instance of HTTPError.



16
17
18
19
# File 'lib/iconoclasm/errors.rb', line 16

def initialize(url, response)
  super(url)
  @response = response
end

Instance Method Details

#codeObject



28
29
30
# File 'lib/iconoclasm/errors.rb', line 28

def code
  @response.respond_to?(:response_code) ? @response.response_code : @response[/\d{3}/]
end

#http_error_messageObject



36
37
38
# File 'lib/iconoclasm/errors.rb', line 36

def http_error_message
  "#{@code}: #{http_error_reason}"
end

#http_error_reasonObject



32
33
34
# File 'lib/iconoclasm/errors.rb', line 32

def http_error_reason
  @response.respond_to?(:header_str) ? error_reason : @response
end

#messageObject



21
22
23
24
25
26
# File 'lib/iconoclasm/errors.rb', line 21

def message
  msg = ""
  msg += "There was a problem getting #{@url} " if @url
  msg += "(#{http_error_reason})"
  msg
end