Skip to content

Commit c5ae4d7

Browse files
committed
add some debug options for the broad exception handler
1 parent 809b423 commit c5ae4d7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/logger.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import sys
3+
from functools import wraps
34
from logging.handlers import RotatingFileHandler
45

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

1617

17-
def BroadErrorHandler(func):
18-
def innerFunction(*args, **kwargs):
19-
try:
20-
func(*args, **kwargs)
21-
except Exception as e:
22-
logger.error(f"An error occurred at {func.__name__}")
23-
logger.error(str(e))
18+
def BroadErrorHandler(logger):
19+
def decorator(func):
20+
@wraps(func)
21+
def innerFunction(*args, **kwargs):
22+
try:
23+
result = func(*args, **kwargs)
24+
return result
25+
except Exception as e:
26+
logger.error(f"An error occurred at {func.__name__}")
27+
logger.error(str(e))
28+
# raise ValueError("Debug") from e
2429

25-
return innerFunction
30+
return innerFunction
31+
return decorator

0 commit comments

Comments
 (0)