in infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/mapper/PostgreSQLDialectExceptionMapper.java [53:103]
public SQLException convert(final SQLDialectException sqlDialectException) {
if (sqlDialectException instanceof UnknownDatabaseException) {
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.INVALID_CATALOG_NAME, ((UnknownDatabaseException) sqlDialectException).getDatabaseName()));
}
if (sqlDialectException instanceof DatabaseCreateExistsException) {
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.DUPLICATE_DATABASE, ((DatabaseCreateExistsException) sqlDialectException).getDatabaseName()));
}
if (sqlDialectException instanceof NoSuchTableException) {
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.NO_SUCH_TABLE, ((NoSuchTableException) sqlDialectException).getTableName()));
}
if (sqlDialectException instanceof TableExistsException) {
return new PostgreSQLException(new ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.DUPLICATE_TABLE, ((TableExistsException) sqlDialectException).getTableName()));
}
if (sqlDialectException instanceof InTransactionException) {
return new PostgreSQLException(new ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.TRANSACTION_STATE_INVALID));
}
if (sqlDialectException instanceof InsertColumnsAndValuesMismatchedException) {
return new PostgreSQLException(new ServerErrorMessage(ERROR_SEVERITY,
PostgreSQLVendorError.WRONG_VALUE_COUNT_ON_ROW, ((InsertColumnsAndValuesMismatchedException) sqlDialectException).getMismatchedRowNumber()));
}
if (sqlDialectException instanceof InvalidParameterValueException) {
InvalidParameterValueException cause = (InvalidParameterValueException) sqlDialectException;
return new PostgreSQLException(new ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.INVALID_PARAMETER_VALUE, cause.getParameterName(), cause.getParameterValue()));
}
if (sqlDialectException instanceof TooManyConnectionsException) {
return new PostgreSQLException(new ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.DATA_SOURCE_REJECTED_CONNECTION_ATTEMPT));
}
if (sqlDialectException instanceof UnknownUsernameException) {
return new PostgreSQLException(new ServerErrorMessage(
FATAL_SEVERITY, PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION, ((UnknownUsernameException) sqlDialectException).getUsername()));
}
if (sqlDialectException instanceof InvalidPasswordException) {
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.INVALID_PASSWORD, ((InvalidPasswordException) sqlDialectException).getUsername()));
}
if (sqlDialectException instanceof PrivilegeNotGrantedException) {
PrivilegeNotGrantedException cause = (PrivilegeNotGrantedException) sqlDialectException;
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.PRIVILEGE_NOT_GRANTED, cause.getUsername(), cause.getDatabaseName()));
}
if (sqlDialectException instanceof EmptyUsernameException) {
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.NO_USERNAME));
}
if (sqlDialectException instanceof ProtocolViolationException) {
ProtocolViolationException cause = (ProtocolViolationException) sqlDialectException;
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.PROTOCOL_VIOLATION, cause.getExpectedMessageType(), cause.getActualMessageType()));
}
if (sqlDialectException instanceof ColumnNotFoundException) {
ColumnNotFoundException cause = (ColumnNotFoundException) sqlDialectException;
return new PostgreSQLException(new ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.UNDEFINED_COLUMN, cause.getTableName(), cause.getColumnName()));
}
return new PostgreSQLException(sqlDialectException.getMessage(), PostgreSQLState.UNEXPECTED_ERROR.getValue());
}