Class SqlExceptionUtils

java.lang.Object
com.example.blogs.app.util.SqlExceptionUtils

@Component public class SqlExceptionUtils extends Object
Utility for analyzing PostgreSQL exceptions and extracting constraint violation details.
  • Constructor Details

    • SqlExceptionUtils

      public SqlExceptionUtils()
  • Method Details

    • containsUniqueViolation

      public boolean containsUniqueViolation(Throwable t, String columnName)
      Checks if an exception chain contains a PostgreSQL unique constraint violation for a specific column.
      Parameters:
      t - the exception to analyze (including nested causes)
      columnName - the column name to check in the constraint violation message
      Returns:
      true if a unique violation on the specified column is found