class Hibp::ServiceError

Hibp::ServiceError

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

Attributes

body[R]
raw_body[R]
status_code[R]

Public Class Methods

new(message = '', params = {}) click to toggle source

@param message [String] - (optional, '') Message to describe an error @param params [Hash] - (optional, {}) Additional error information

@option params [String] :body -

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

@option params [String] :title -

Error summary

@option params [String] :detail -

Error detailed description

@option params [String] :raw_body -

Raw body from response

@option params [String] :status_code -

Http status code
Calls superclass method
# 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

Public Instance Methods

to_s() click to toggle source
# File lib/hibp/service_error.rb, line 37
def to_s
  "#{super} #{instance_variables_to_s}"
end

Private Instance Methods

instance_variables_to_s() click to toggle source
# File lib/hibp/service_error.rb, line 43
def instance_variables_to_s
  attr_values = %i[body raw_body status_code].map do |attr|
    attr_value = send(attr)

    "@#{attr}=#{attr_value.inspect}"
  end

  attr_values.join(', ')
end