Module: Cts::Mpx::Driver::Exceptions

Defined in:
lib/cts/mpx/driver/exceptions.rb

Overview

custom exception method helpers

Class Method Summary collapse

Class Method Details

.raise_unless_account_id(argument) ⇒ nil

Raise an ArgumentError if the argument does not pass Validators.account_id?

Parameters:

  • argument (Object)

    argument to test if it is a valid account_id

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    if the argument is not a valid account_id



12
13
14
15
16
# File 'lib/cts/mpx/driver/exceptions.rb', line 12

def (argument)
  raise ArgumentError, "#{argument} is not a valid account_id" unless Validators. argument

  nil
end

.raise_unless_argument_error?(data, type = nil, &block) ⇒ nil

Raise an ArgumentError if the argument is not of the supplied type

Parameters:

  • data (Object)

    argument to test if it is the correct type

  • type (Object) (defaults to: nil)

    type to test for

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    if the argument is not of the correct type



23
24
25
26
27
# File 'lib/cts/mpx/driver/exceptions.rb', line 23

def raise_unless_argument_error?(data, type = nil, &block)
  raise(ArgumentError, "#{data || 'nil'} is not a valid #{type}") if Validators.argument_error?(data, type, &block)

  nil
end

.raise_unless_reference?(argument) ⇒ nil

Raise an ArgumentError if the argument does not pass Validators.reference?

Parameters:

  • argument (Object)

    argument to test if it is a valid reference

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    if the argument is not a valid reference



33
34
35
36
37
# File 'lib/cts/mpx/driver/exceptions.rb', line 33

def raise_unless_reference?(argument)
  raise ArgumentError, "#{argument} is not a valid reference" unless Validators.reference? argument

  nil
end

.raise_unless_required_keyword?(a_binding, keyword) ⇒ nil

Raise an ArgumentError if the keyword is not supplied.

Parameters:

  • keyword (Object)

    keyword to assure is supplied

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    if the keyword is not suppplied



43
44
45
46
47
48
# File 'lib/cts/mpx/driver/exceptions.rb', line 43

def raise_unless_required_keyword?(a_binding, keyword)
  value = a_binding.local_variable_get(keyword)
  raise ArgumentError, "#{keyword} is a required keyword." unless value

  nil
end