Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/src/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ function* testDatasourceSaga(actionPayload: ReduxAction<Datasource>) {
id: datasource.id,
environmentId: currentEnvironment,
show: true,
error: { message: responseData.invalids.join(", ") },
error: { message: responseData.invalids.join("\n") },
},
});
AppsmithConsole.error({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 @@ -1347,10 +1349,21 @@ private static HikariDataSource createConnectionPool(
try {
datasource = new HikariDataSource(config);
} catch (PoolInitializationException e) {
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());
}
}
throw new AppsmithPluginException(
AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
PostgresErrorMessages.CONNECTION_POOL_CREATION_FAILED_ERROR_MSG,
e.getMessage());
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.";
}