justinmclean opened a new issue, #8166:
URL: https://github.com/apache/gravitino/issues/8166

   ### What would you like to be improved?
   
   In 
core/src/main/java/org/apache/gravitino/storage/relational/converters/PostgreSQLExceptionConverter.java,
 SQL exception codes are treated as a number, which is incorrect. e.g. 28P01 
means invalid password
   
   Here are some tests to show that.
   ```
     @Test
     public void testConvertDuplicatedEntryException() {
       SQLException sqlException = new SQLException("duplicate", "23505");
       PostgreSQLExceptionConverter converter = new 
PostgreSQLExceptionConverter();
       Assertions.assertThrows(
           EntityAlreadyExistsException.class,
           () -> converter.toGravitinoException(sqlException, 
Entity.EntityType.METALAKE, "test"),
           String.format("The %s entity: %s already exists.", 
Entity.EntityType.METALAKE, "test"));
     }
   
     @Test
     public void testNonNumericSqlStateHandledAsIOException() {
       SQLException sqlException = new SQLException("error", "28P01");
       PostgreSQLExceptionConverter converter = new 
PostgreSQLExceptionConverter();
       Assertions.assertThrows(
           IOException.class,
           () -> converter.toGravitinoException(sqlException, 
Entity.EntityType.METALAKE, "test"));
     }
   ```
   
   ### How should we improve?
   
   Treat them as strings. Note currently a java.lang.NumberFormatException will 
be thrown.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to