Skip to content

Commit

Permalink
add some debug options for the broad exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mwinkens committed Jul 16, 2024
1 parent 809b423 commit c5ae4d7
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import sys
from functools import wraps
from logging.handlers import RotatingFileHandler

handlers = [RotatingFileHandler(filename="simple_ddnet_mapper.log",
Expand All @@ -14,12 +15,17 @@
datefmt='%m/%d/%Y%I:%M:%S %p')


def BroadErrorHandler(func):
def innerFunction(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception as e:
logger.error(f"An error occurred at {func.__name__}")
logger.error(str(e))
def BroadErrorHandler(logger):
def decorator(func):
@wraps(func)
def innerFunction(*args, **kwargs):
try:
result = func(*args, **kwargs)
return result
except Exception as e:
logger.error(f"An error occurred at {func.__name__}")
logger.error(str(e))
# raise ValueError("Debug") from e

return innerFunction
return innerFunction
return decorator

0 comments on commit c5ae4d7

Please sign in to comment.