Module: Cts::Mpx::Driver::Exceptions
- Defined in:
- lib/cts/mpx/driver/exceptions.rb
Overview
custom exception method helpers
Class Method Summary collapse
-
.raise_unless_account_id(argument) ⇒ nil
Raise an ArgumentError if the argument does not pass Validators.account_id?.
-
.raise_unless_argument_error?(data, type = nil, &block) ⇒ nil
Raise an ArgumentError if the argument is not of the supplied type.
-
.raise_unless_reference?(argument) ⇒ nil
Raise an ArgumentError if the argument does not pass Validators.reference?.
-
.raise_unless_required_keyword?(a_binding, keyword) ⇒ nil
Raise an ArgumentError if the keyword is not supplied.
Class Method Details
.raise_unless_account_id(argument) ⇒ nil
Raise an ArgumentError if the argument does not pass Validators.account_id?
12 13 14 15 16 |
# File 'lib/cts/mpx/driver/exceptions.rb', line 12 def raise_unless_account_id(argument) raise ArgumentError, "#{argument} is not a valid account_id" unless Validators.account_id? argument nil end |
.raise_unless_argument_error?(data, type = nil, &block) ⇒ nil
Raise an ArgumentError if the argument is not of the supplied 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?
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.
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 |