# Path: ipwb/error_handler.py
# def exception_logger(catch=True, exception_class=Exception):
#     """
#     Decorator which catches exceptions in the function and logs them.
# 
#     Usage:
# 
#     ```python
#     @exception_logger()
#     def decorated_function(foo, bar):
#         do_something
#     ```
# 
#     `exception_logger()` will catch any exception which happens in
#     `decorated_function()` while it is being executed, and log an error using
#     Python built in `logging` library.
# 
#     Unless `catch` argument is `False` - in which case the exception will be
#     reraised.
#     """
#     def decorator(f: Callable):
#         @functools.wraps(f)
#         def wrapper(*args, **kwargs):
#             try:
#                 return f(*args, **kwargs)
# 
#             except exception_class as err:
#                 if catch:
#                     logger.critical(str(err))
# 
#                 else:
#                     raise
# 
#         return wrapper
# 
#     return decorator


import pytest
from unittest.mock import MagicMock, patch
from ipwb.error_handler import exception_logger



@exception_logger(catch=False)
def reraised_error(arg):
    raise Exception(arg)



# Path: ipwb/error_handler.py
# def exception_logger(catch=True, exception_class=Exception):
#     """
#     Decorator which catches exceptions in the function and logs them.
# 
#     Usage:
# 
#     ```python
#     @exception_logger()
#     def decorated_function(foo, bar):
#         do_something
#     ```
# 
#     `exception_logger()` will catch any exception which happens in
#     `decorated_function()` while it is being executed, and log an error using
#     Python built in `logging` library.
# 
#     Unless `catch` argument is `False` - in which case the exception will be
#     reraised.
#     """
#     def decorator(f: Callable):
#         @functools.wraps(f)
#         def wrapper(*args, **kwargs):
#             try:
#                 return f(*args, **kwargs)
# 
#             except exception_class as err:
#                 if catch:
#                     logger.critical(str(err))
# 
#                 else:
#                     raise
# 
#         return wrapper
# 
#     return decorator


# Path: tests/test_error_handler.py
import pytest
from unittest.mock import MagicMock, patch
from ipwb.error_handler import exception_logger




@exception_logger(catch=False)
def reraised_error(arg):
    raise Exception(arg)



@exception_logger()