File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 11import logging
22import sys
3+ from functools import wraps
34from logging .handlers import RotatingFileHandler
45
56handlers = [RotatingFileHandler (filename = "simple_ddnet_mapper.log" ,
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
You can’t perform that action at this time.
0 commit comments