Module: Antrapol::ToolRack::ExceptionUtils

Includes:
ConditionUtils
Defined in:
lib/toolrack/exception_utils.rb

Instance Method Summary collapse

Instance Method Details

#raise_if_empty(val, message, error = StandardError) ⇒ Object Also known as: raise_if_empty?

raise_if_empty Raise the given (or default if not given) exception if the val given is empty val - variable/object that shall be tested for emptiness message - message to be thrown if it is true error - exception object to be thrown



14
15
16
# File 'lib/toolrack/exception_utils.rb', line 14

def raise_if_empty(val, message, error = StandardError)
  raise_error(message,error) if is_empty?(val)
end

#raise_if_false(bool, message, error = StandardError) ⇒ Object Also known as: raise_if_false?

raise_if_false



22
23
24
25
26
# File 'lib/toolrack/exception_utils.rb', line 22

def raise_if_false(bool, message, error = StandardError)
  if not bool
    raise_error(message,error)
  end 
end

#raise_if_true(bool, message, error = StandardError) ⇒ Object Also known as: raise_if_true?

raise_if_true



32
33
34
# File 'lib/toolrack/exception_utils.rb', line 32

def raise_if_true(bool, message, error = StandardError)
  raise_if_false(!bool, message, error)
end