Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: shadow PR for external contribution #ce-35167 #36053

Merged
merged 10 commits into from
Sep 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.pf4j.Extension;
import org.pf4j.PluginWrapper;
import org.postgresql.util.PGobject;
import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -1320,10 +1322,27 @@ private static HikariDataSource createConnectionPool(
try {
datasource = new HikariDataSource(config);
} catch (PoolInitializationException e) {
throw new AppsmithPluginException(
AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
PostgresErrorMessages.CONNECTION_POOL_CREATION_FAILED_ERROR_MSG,
e.getMessage());
Throwable cause = e.getCause();
if (cause instanceof PSQLException) {
PSQLException psqlException = (PSQLException) cause;
String sqlState = psqlException.getSQLState();
if (PSQLState.CONNECTION_UNABLE_TO_CONNECT.getState().equals(sqlState)) {
throw new AppsmithPluginException(
AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
PostgresErrorMessages.DS_INVALID_HOSTNAME_AND_PORT_MSG,
psqlException.getMessage());
} else {
throw new AppsmithPluginException(
AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
PostgresErrorMessages.CONNECTION_POOL_CREATION_FAILED_ERROR_MSG,
cause.getMessage());
}
} else {
throw new AppsmithPluginException(
AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
PostgresErrorMessages.CONNECTION_POOL_CREATION_FAILED_ERROR_MSG,
cause != null ? cause.getMessage() : e.getMessage());
}
}

return datasource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ public class PostgresErrorMessages extends BasePluginErrorMessages {
public static final String DS_MISSING_PASSWORD_ERROR_MSG = "Missing password for authentication.";

public static final String DS_MISSING_DATABASE_NAME_ERROR_MSG = "Missing database name.";

public static final String DS_INVALID_HOSTNAME_AND_PORT_MSG = "Please check the host and port.";
}
Loading