Skip to content

Commit 15b6d46

Browse files
authored
[DH-5724] Fix refresh error handler (#459)
1 parent a11d1f1 commit 15b6d46

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

dataherald/api/fastapi.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,18 @@ def refresh_table_description(
224224
try:
225225
sql_database = SQLDatabase.get_sql_engine(db_connection, True)
226226
tables = sql_database.get_tables_and_views()
227+
228+
# Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED
229+
scanner_repository = TableDescriptionRepository(self.storage)
230+
scanner = self.system.instance(Scanner)
231+
return [
232+
TableDescriptionResponse(**record.dict())
233+
for record in scanner.refresh_tables(
234+
tables, str(db_connection.id), scanner_repository
235+
)
236+
]
227237
except Exception as e:
228-
raise HTTPException( # noqa: B904
229-
status_code=400,
230-
detail=f"{e}",
231-
)
232-
# Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED
233-
scanner_repository = TableDescriptionRepository(self.storage)
234-
scanner = self.system.instance(Scanner)
235-
return [
236-
TableDescriptionResponse(**record.dict())
237-
for record in scanner.refresh_tables(
238-
tables, str(db_connection.id), scanner_repository
239-
)
240-
]
238+
return error_response(e, refresh_table_description.dict(), "refresh_failed")
241239

242240
@override
243241
def list_database_connections(self) -> list[DatabaseConnectionResponse]:

0 commit comments

Comments
 (0)