Exception: NWS::APIError

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

Overview

Error raised when the NWS API returns an error response

Direct Known Subclasses

NotFoundError, RateLimitError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: nil, response_body: nil) ⇒ APIError

Returns a new instance of APIError.

Parameters:

  • message (String)

    Error message

  • status_code (Integer, nil) (defaults to: nil)

    HTTP status code

  • response_body (String, nil) (defaults to: nil)

    Raw response body



18
19
20
21
22
# File 'lib/nws/errors.rb', line 18

def initialize(message, status_code: nil, response_body: nil)
  @status_code = status_code
  @response_body = response_body
  super(message)
end

Instance Attribute Details

#response_bodyString? (readonly)

Returns Raw response body from the API.

Returns:

  • (String, nil)

    Raw response body from the API



13
14
15
# File 'lib/nws/errors.rb', line 13

def response_body
  @response_body
end

#status_codeInteger? (readonly)

Returns HTTP status code from the API response.

Returns:

  • (Integer, nil)

    HTTP status code from the API response



10
11
12
# File 'lib/nws/errors.rb', line 10

def status_code
  @status_code
end