Create attractive VASL scenarios, with loads of useful information embedded to assist with game play. https://vasl-templates.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
vasl-templates/vasl_templates/utils.py

23 lines
762 B

""" Miscellaneous utilities. """
import functools
import logging
import traceback
# ---------------------------------------------------------------------
def log_exceptions( caption="EXCEPTION" ):
"""Decorator that logs exceptions thrown by the wrapped function."""
def decorator( func ):
"""The real decorator function."""
@functools.wraps( func )
def wrapper( *args, **kwargs ):
"""Wrapper around the function being decorated."""
try:
return func( *args, **kwargs )
except Exception as ex:
logging.critical( "%s: %s", caption, ex )
logging.critical( traceback.format_exc() )
raise
return wrapper
return decorator