Exception: RipeDbClient::BadParameter

Inherits:
Error
  • Object
show all
Defined in:
lib/ripe_db_client/exceptions.rb

Overview

This error is raised when a user has not specified a value for a mandatory parameter

raise RipeDbClient::BadParameter.new("search parameter missing", "dblookup")

The passed message, action, and subject are optional and can later be retrieved when rescuing from the exception.

exception.message # => "search parameter missing"
exception.action # => "dblookup"

If the message is not specified (or is nil) it will default to “You have an Invalid or Missing Parameter” This default can be overridden by setting default_message.

exception.default_message = "Default error message"
exception.message # => "Default error message"

Author:

  • Mike Simkins

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, action = nil, subject = nil) ⇒ BadParameter



35
36
37
38
39
40
# File 'lib/ripe_db_client/exceptions.rb', line 35

def initialize (message = nil, action = nil, subject = nil)
  @message = message
  @action = action
  @subject = subject
  @default_message = "You have an Invalid or Missing Parameter"
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



32
33
34
# File 'lib/ripe_db_client/exceptions.rb', line 32

def action
  @action
end

#default_message=(value) ⇒ Object (writeonly)

Sets the attribute default_message



33
34
35
# File 'lib/ripe_db_client/exceptions.rb', line 33

def default_message=(value)
  @default_message = value
end

#subjectObject (readonly)

Returns the value of attribute subject.



32
33
34
# File 'lib/ripe_db_client/exceptions.rb', line 32

def subject
  @subject
end

Instance Method Details

#to_sString



44
45
46
# File 'lib/ripe_db_client/exceptions.rb', line 44

def to_s
  @message || @default_message
end