Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can the error severity be removed from the error message created by Postgresql#1268

AbhinashJha342 started this conversation inGeneral
Discussion options

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 thrown by Postgres seems to be starting with "ERROR:" and I am exploring options if it can be removed through superuser.

I have raised a similar questionhere.

Any suggestions or confirmation if it can or cannot be done is appreciated.
Thanks!

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

The best I can find ishttps://www.postgresql.org/docs/current/runtime-config-logging.html#GUC-LOG-MIN-ERROR-STATEMENT -- ie, settinglog_min_error_statement=PANIC, which will remove theERROR logs entirely (which doesn't sound like it's what you want, unfortunately).

There does appear to be a JSON format for the logs (https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-JSONLOG) which might be interesting and allow you to better parse/filter these messages with another tool?

You must be logged in to vote
1 reply
@AbhinashJha342
Comment options

actually, its a big application with many sql messages, and removing "ERROR:" keyword from the message after SQLException is caught is the last resort. on debugging, I find that thetoString() method ofServerErrorMessage class creates the final message. I was just thinking if there is a way to intercept this method call and make some changes. I am using Java and Jdbc. Below is the method fromorg.postgresql.util.PSQLException which calls thetoString()

public PSQLException(ServerErrorMessage serverError, boolean detail) {        super(detail ? serverError.toString() : serverError.getNonSensitiveErrorMessage(), serverError.getSQLState());        this.serverError = serverError;    }
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@AbhinashJha342@tianon

[8]ページ先頭

©2009-2025 Movatter.jp