From ed5c67cf1b173d755eae2d2a91d8a59a699f7cd6 Mon Sep 17 00:00:00 2001 From: Juan Carlos Jose Camacho Date: Wed, 10 Apr 2024 17:06:13 -0600 Subject: [PATCH] [DH-5724] Fix refresh error handler --- dataherald/api/fastapi.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/dataherald/api/fastapi.py b/dataherald/api/fastapi.py index be81aab7..d854da05 100644 --- a/dataherald/api/fastapi.py +++ b/dataherald/api/fastapi.py @@ -224,20 +224,18 @@ def refresh_table_description( try: sql_database = SQLDatabase.get_sql_engine(db_connection, True) tables = sql_database.get_tables_and_views() + + # Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED + scanner_repository = TableDescriptionRepository(self.storage) + scanner = self.system.instance(Scanner) + return [ + TableDescriptionResponse(**record.dict()) + for record in scanner.refresh_tables( + tables, str(db_connection.id), scanner_repository + ) + ] except Exception as e: - raise HTTPException( # noqa: B904 - status_code=400, - detail=f"{e}", - ) - # Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED - scanner_repository = TableDescriptionRepository(self.storage) - scanner = self.system.instance(Scanner) - return [ - TableDescriptionResponse(**record.dict()) - for record in scanner.refresh_tables( - tables, str(db_connection.id), scanner_repository - ) - ] + return error_response(e, refresh_table_description.dict(), "refresh_failed") @override def list_database_connections(self) -> list[DatabaseConnectionResponse]: