Exception: Hacker::News::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/hacker/news/errors.rb

Overview

Base error class. Every exception the client raises is a subclass of this.

Direct Known Subclasses

HttpError, JsonError, TimeoutError, TransportError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, url: nil, status: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String)
  • url (String, nil) (defaults to: nil)
  • status (Integer, nil) (defaults to: nil)


17
18
19
20
21
# File 'lib/hacker/news/errors.rb', line 17

def initialize(message, url: nil, status: nil)
  super(message)
  @url = url
  @status = status
end

Instance Attribute Details

#statusInteger? (readonly)

Returns the HTTP status code, when applicable.

Returns:

  • (Integer, nil)

    the HTTP status code, when applicable.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hacker/news/errors.rb', line 11

class Error < StandardError
  attr_reader :url, :status

  # @param message [String]
  # @param url [String, nil]
  # @param status [Integer, nil]
  def initialize(message, url: nil, status: nil)
    super(message)
    @url = url
    @status = status
  end
end

#urlString? (readonly)

Returns the URL being fetched when the error occurred.

Returns:

  • (String, nil)

    the URL being fetched when the error occurred.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hacker/news/errors.rb', line 11

class Error < StandardError
  attr_reader :url, :status

  # @param message [String]
  # @param url [String, nil]
  # @param status [Integer, nil]
  def initialize(message, url: nil, status: nil)
    super(message)
    @url = url
    @status = status
  end
end