Exception: Hibp::ServiceError

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

Overview

Hibp::ServiceError

Used to represent an error that may occur when performing a request to the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = '', params = {}) ⇒ ServiceError

Returns a new instance of ServiceError.

Parameters:

  • message (String) (defaults to: '')
    • (optional, ”) Message to describe an error

  • params (Hash) (defaults to: {})
    • (optional, {}) Additional error information

Options Hash (params):

  • :body (String)

    - A JSON formatted error object that provides more details about the specifics of the error

  • :title (String)

    - Error summary

  • :detail (String)

    - Error detailed description

  • :raw_body (String)

    - Raw body from response

  • :status_code (String)

    - Http status code



29
30
31
32
33
34
35
# File 'lib/hibp/service_error.rb', line 29

def initialize(message = '', params = {})
  @body         = params[:body]
  @raw_body     = params[:raw_body]
  @status_code  = params[:status_code]

  super(message)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/hibp/service_error.rb', line 9

def body
  @body
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



9
10
11
# File 'lib/hibp/service_error.rb', line 9

def raw_body
  @raw_body
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



9
10
11
# File 'lib/hibp/service_error.rb', line 9

def status_code
  @status_code
end

Instance Method Details

#to_sObject



37
38
39
# File 'lib/hibp/service_error.rb', line 37

def to_s
  "#{super} #{instance_variables_to_s}"
end