util
util.functions
- texasholdem.util.functions.check_raise(exc_type)[source]
Decorator that turns a function that returns a bool and message into a function that returns a bool and optionally throws an error.
Injects argument throws (bool): default False.
Example
You can use the decorator like so:
@check_raise(ValueError) def validate(arg1): return False, "test" validate("arg1") # will return False validate("arg1", throws=True) # will raise ValueError("test")
- Parameters:
exc_type (Type[Exception]) – The Exception type to throw.
- texasholdem.util.functions.handle(handler, exc_type=<class 'Exception'>)[source]
Decorator that wraps the entire function in a try-except statement that catches the given
exc_typeand handles it with the given handler.- Parameters:
exc_type (Type[Exception]) – The exception type to handle
handler – Function that handles the exc_type exception