1.新增水准线路补充检测接口

This commit is contained in:
whm
2026-03-15 10:42:01 +08:00
parent dd9f31ee52
commit 42dab6f961
5 changed files with 248 additions and 8 deletions

View File

@@ -235,10 +235,11 @@ def receive_after_cursor_execute(conn, cursor, statement, params, context, execu
log_transaction_end(success=True)
@event.listens_for(Engine, "handle_error")
def receive_handle_error(exception, context):
"""错误监听"""
error_msg = str(exception)
sql = context.statement if context and hasattr(context, 'statement') else None
def receive_handle_error(context):
"""错误监听SQLAlchemy 只传入一个 ExceptionContext 参数"""
exception = getattr(context, "original_exception", None) or getattr(context, "sqlalchemy_exception", None)
error_msg = str(exception) if exception else str(context)
sql = getattr(context, "statement", None)
log_connection_error(error_msg, sql)
log_transaction_end(success=False, error=error_msg)