[Answer]-Format of PostgreSQL trigger exception text depend on system?

1👍

✅

PostgreSQL reports errors translated into the locale of the database. If you don’t want that you can change LC_MESSAGES at CREATE DATABASE time (or possibly with ALTER DATABASE, I haven’t checked).

However, you shouldn’t be parsing error messages. Use the extended error message structure – accessible via psycopg2.extensions.Diagnostics. Use one of the RAISE forms that lets you specify a DETAIL message and store your app payload in there, and use a custom SQLSTATE to indicate to your app that it’s an application specific message with payload in detail.

PostgreSQL may (and has, in the past) change error message formats. Don’t rely on being able to parse them.

Leave a comment