Is there a way to remove the "ERROR:" from the error message that postgresql sends? Adding a sample error message :
ERROR: insert or update on table "bonus" violates foreign key constraint "bonus_cust_id_fkey"
Detail: Key (cust_id)=(1998) is not present in table "customer"
All SQLException seems to be starting with "ERROR:" and I am exploring options if it can be removed through superuser. The documentation here mentions about configuring the logger levels through superuser, so I am thinking if there is an option to remove "ERROR:" keyword from message.
I have further explained this issue here and was advised to ask here.
If it cannot be done by superuser, then is there a way to modify it through code? I am using java and jdbc.
This is the method from QueryExecutorImpl class where error message is created:
private SQLException receiveErrorResponse() throws IOException {
int elen = this.pgStream.receiveInteger4();
assert elen > 4 : "Error response length must be greater than 4";
EncodingPredictor.DecodeResult totalMessage = this.pgStream.receiveErrorString(elen - 4);
ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " <=BE ErrorMessage({0})", errorMsg.toString());
}
PSQLException error = new PSQLException(errorMsg, this.logServerErrorDetail);
if (this.transactionFailCause == null) {
this.transactionFailCause = error;
} else {
error.initCause(this.transactionFailCause);
}
return error;
}
Just thinking, if there is a way in java to intercept and change when the error message is created.