Exception: RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sideko_hacker_news.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, method, url, message) ⇒ RequestError

Returns a new instance of RequestError.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sideko_hacker_news.rb', line 9

def initialize(status_code, method, url, message)
  @status_code = status_code
  @method = method
  @url = url
  begin
    @data = JSON.parse(message)
  rescue
    @data = message
  end

  super("received #{status_code} from #{method} #{url} with #{message}")
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/sideko_hacker_news.rb', line 7

def data
  @data
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/sideko_hacker_news.rb', line 7

def method
  @method
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



7
8
9
# File 'lib/sideko_hacker_news.rb', line 7

def status_code
  @status_code
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/sideko_hacker_news.rb', line 7

def url
  @url
end