eye.utils module

eye.utils.exception_logging(reraise=True, logger=None, level=40)[source]

Context manager to log exceptions

eye.utils.exceptionLogging(reraise=True, logger=None, level=logging.ERROR)

Within this context, if an exception is raised and not caught, the exception is logged, and the exception continues upper in the stack frames.

Parameters:
  • reraise – if False, uncaught exceptions will be intercepted and not be raised to upper frames (but the code in this context is still interrupted and aborted)

  • logger – logger where to log the exceptions. If None, the root logger is used

  • level – level with which to log the exceptions

Example of exception interception:

try:
        with exception_logging():
                raise RuntimeError('Unexpected error')
except Exception as e:
        pass

# is equivalent to

with exceptionLogging(reraise=False):
        raise RuntimeError('Unexpected error')
eye.utils.ignore_exceptions(return_value, logger=None, level=40)[source]