API Reference

class merry.Merry(logger_name='merry', debug=False)

Initialze merry.

Parameters:
  • logger_name – the logger name to use. The default is 'merry'.

  • debug – set to True to enable debug mode, which causes all errors to bubble up so that a debugger can catch them. The default is False.

_try(f)

Decorator that wraps a function in a try block.

Example usage:

@merry._try
def my_function():
    # do something here
_except(*args, **kwargs)

Decorator that registers a function as an error handler for one or more exception classes.

Example usage:

@merry._except(RuntimeError)
def runtime_error_handler(e):
    print('runtime error:', str(e))
Parameters:
  • args – the list of exception classes to be handled by the decorated function.

  • kwargs – configuration arguments. Pass debug=True to enable debug mode for this handler, which bubbles up all exceptions. Pass debug=False to prevent the error from bubbling up, even if debug mode is enabled globally.

_else(f)

Decorator to define the else clause handler.

Example usage:

@merry._else
def else_handler():
    print('no exceptions were raised')
_finally(f)

Decorator to define the finally clause handler.

Example usage:

@merry._finally
def finally_handler():
    print('clean up')