|
8 | 8 |
|
9 | 9 | from apps.db.engine import create_table, get_data_engine, insert_data |
10 | 10 | from common.core.deps import SessionDep, CurrentUser, Trans |
| 11 | +from common.utils.utils import SQLBotLogUtil |
11 | 12 | from ..crud.datasource import get_datasource_list, check_status, create_ds, update_ds, delete_ds, getTables, getFields, \ |
12 | 13 | execSql, update_table_and_fields, getTablesByDs, chooseTables, preview, updateTable, updateField, get_ds, fieldEnum |
13 | 14 | from ..crud.field import get_fields_by_table_id |
@@ -60,7 +61,11 @@ async def get_tables(session: SessionDep, id: int): |
60 | 61 |
|
61 | 62 | @router.post("/getTablesByConf") |
62 | 63 | async def get_tables_by_conf(session: SessionDep, ds: CoreDatasource): |
63 | | - return getTablesByDs(session, ds) |
| 64 | + try: |
| 65 | + return getTablesByDs(session, ds) |
| 66 | + except Exception as e: |
| 67 | + SQLBotLogUtil.error(f"get table failed: {e}") |
| 68 | + raise HTTPException(status_code=500, detail=f'Get table Failed: {e.args}') |
64 | 69 |
|
65 | 70 |
|
66 | 71 | @router.post("/getFields/{id}/{table_name}") |
@@ -100,7 +105,11 @@ async def edit_field(session: SessionDep, field: CoreField): |
100 | 105 |
|
101 | 106 | @router.post("/previewData/{id}") |
102 | 107 | async def edit_local(session: SessionDep, current_user: CurrentUser, id: int, data: TableObj): |
103 | | - return preview(session, current_user, id, data) |
| 108 | + try: |
| 109 | + return preview(session, current_user, id, data) |
| 110 | + except Exception as e: |
| 111 | + SQLBotLogUtil.error(f"Preview failed: {e}") |
| 112 | + raise HTTPException(status_code=500, detail=f'Preview Failed: {e.args}') |
104 | 113 |
|
105 | 114 |
|
106 | 115 | @router.post("/fieldEnum/{id}") |
|
0 commit comments