16 lines
		
	
	
		
			464 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			464 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from functools import wraps
 | 
						|
from codes.common import db_operation
 | 
						|
 | 
						|
def handle_exception(module, stop: bool = False):
 | 
						|
    def exceptions(func):
 | 
						|
        @wraps(func)
 | 
						|
        def wrapper(*args, **kwargs):
 | 
						|
            try:
 | 
						|
                return func(*args, **kwargs)
 | 
						|
            except Exception as e:
 | 
						|
                db_operation.db_write_logs(e, module, "exception")
 | 
						|
                if stop:
 | 
						|
                    raise e
 | 
						|
        return wrapper
 | 
						|
    return exceptions
 |