From fdb9a143af2b4047150568edcf6fb4b7a359fc54 Mon Sep 17 00:00:00 2001 From: Giorgio Trettenero Date: Wed, 4 Dec 2024 03:25:28 -0800 Subject: [PATCH] minor changes --- .../connector/polaris/PolarisConnectorDatabaseService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/PolarisConnectorDatabaseService.java b/metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/PolarisConnectorDatabaseService.java index f63c5623..8b5b5edd 100644 --- a/metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/PolarisConnectorDatabaseService.java +++ b/metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/PolarisConnectorDatabaseService.java @@ -89,15 +89,14 @@ public void delete(final ConnectorRequestContext context, final QualifiedName na try { this.polarisStoreService.deleteDatabase(name.getDatabaseName()); } catch (DataIntegrityViolationException exception) { - String message = exception.getMessage(); - if (message.contains("violates foreign key constraint") + if (exception.getMessage().contains("violates foreign key constraint") || (exception.getCause() instanceof SQLException && "23503".equals(((SQLException) exception.getCause()).getSQLState()))) { final String errorMessage = String.format( "Failed to delete database %s due to foreign key constraint violation. " + "Ensure all dependent tables are removed first. Error: %s", - name, message + name, exception.getMessage() ); throw new DatabasePreconditionFailedException(name, errorMessage, exception); }