Exception: PurpleAirApi::V1::BaseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/purple_air_api/V1/errors.rb

Overview

A custom error class for rescuing from all PurpleAir API errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, error_type, response_object) ⇒ BaseError

Initialize the error object with error_type and the Faraday response object. PurpleAir returns a human friendly error message and type which is added here. You can also reference the response to view the raw response from PurpleAir.

Parameters:

  • message (String)

    the message you want displayed when the error is raised

  • error_type (String)

    the error type that PurpleAir includes in the JSON response

  • response_object (Faraday::Env)

    the Faraday response object



16
17
18
19
20
# File 'lib/purple_air_api/V1/errors.rb', line 16

def initialize(message, error_type, response_object)
  super(message)
  @error_type = error_type
  @response_object = response_object
end

Instance Attribute Details

#error_typeObject (readonly)

Returns the value of attribute error_type.



7
8
9
# File 'lib/purple_air_api/V1/errors.rb', line 7

def error_type
  @error_type
end

#response_objectObject (readonly)

Returns the value of attribute response_object.



7
8
9
# File 'lib/purple_air_api/V1/errors.rb', line 7

def response_object
  @response_object
end