@@ -1326,6 +1326,20 @@ def _extract_error_message(cls, ex: Exception) -> str:
1326
1326
"""Extract error message for queries"""
1327
1327
return utils .error_msg_from_exception (ex )
1328
1328
1329
+ @classmethod
1330
+ def get_database_custom_errors (
1331
+ cls , database_name : str | None
1332
+ ) -> dict [Any , tuple [str , SupersetErrorType , dict [str , Any ]]]:
1333
+ config_custom_errors = app .config .get ("CUSTOM_DATABASE_ERRORS" , {})
1334
+ if not isinstance (config_custom_errors , dict ):
1335
+ return {}
1336
+
1337
+ if database_name and database_name in config_custom_errors :
1338
+ database_errors = config_custom_errors [database_name ]
1339
+ if isinstance (database_errors , dict ):
1340
+ return database_errors
1341
+ return {}
1342
+
1329
1343
@classmethod
1330
1344
def extract_errors (
1331
1345
cls ,
@@ -1336,21 +1350,7 @@ def extract_errors(
1336
1350
raw_message = cls ._extract_error_message (ex )
1337
1351
1338
1352
context = context or {}
1339
-
1340
- config_custom_errors = app .config .get ("CUSTOM_DATABASE_ERRORS" , {})
1341
-
1342
- if not isinstance (config_custom_errors , dict ):
1343
- config_custom_errors = {}
1344
-
1345
- db_engine_custom_errors = {}
1346
-
1347
- if database_name and database_name in config_custom_errors :
1348
- database_errors = config_custom_errors [database_name ]
1349
- if isinstance (database_errors , dict ):
1350
- db_engine_custom_errors .update (database_errors )
1351
-
1352
- if not isinstance (db_engine_custom_errors , dict ):
1353
- db_engine_custom_errors = {}
1353
+ db_engine_custom_errors = cls .get_database_custom_errors (database_name )
1354
1354
1355
1355
for regex , (message , error_type , extra ) in [
1356
1356
* db_engine_custom_errors .items (),
0 commit comments