Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-CloudSufi committed Dec 18, 2024
1 parent a874989 commit a5405e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

/**
* Error Type provided based on the Snowflake error message code
*
**/
public class SnowflakeErrorType {

//https://github.com/snowflakedb/snowflake-jdbc/blob/master/src/main/java/net/snowflake/client/jdbc/ErrorCode.java
private static final Set<Integer> USER_ERRORS = new HashSet<>(Arrays.asList(
200004, 200006, 200007, 200008, 200009, 200010, 200011, 200012, 200014,
200017, 200018, 200019, 200021, 200023, 200024, 200025, 200026, 200028,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,7 @@ public void checkConnection() {
try (Connection connection = dataSource.getConnection()) {
connection.getMetaData();
} catch (SQLException e) {
String errorMessage = "Cannot create Snowflake connection.";
List<ErrorCode> errorCodes = Arrays.stream(ErrorCode.values()).
filter(errorCode -> errorCode.getSqlState().equals(e.getSQLState())).collect(Collectors.toList());
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorMessage, String.format("Error message: %s", errorMessage),
errorCodes.isEmpty() ? ErrorType.UNKNOWN : SnowflakeErrorType.getErrorType(errorCodes.get(0).getMessageCode()),
true, ErrorCodeType.SQLSTATE, e.getSQLState(),
"https://docs.snowflake.com/en/user-guide/client-connectivity-troubleshooting/error-messages",
new ConnectionTimeoutException(errorMessage, e));
throw new ConnectionTimeoutException("Cannot create Snowflake connection.", e);
} catch (NullPointerException e) {
String errorMessage = "Cannot create Snowflake connection. Username or password is missing.";
throw ErrorUtils.getProgramFailureException(
Expand Down

0 comments on commit a5405e5

Please sign in to comment.