Add PostgreSQL error codes to error message
Currently we are migrating Oracle to PostgreSQL DBExpress. With Oracle, we were able to categorize DBExpress errors based on the message "ORA-XXXXX" and perform appropriate error handling. We had to do this because of the limitation of DBExpress.
With PostgreSQL, we have the problem that we only get the error message. So we would have to parse all error messages individually. Per error code there are 1:n different PostgreSQL error messages!
Therefore our question to you: Would it be possible to set the error code analog to Oracle at the start of the error message?
For example "PG-22023 input string is too short for datetime format".
Maybe this could be turned on or off per customer with a new connection parameter.
As we have seen in various posts, this new feature would certainly be useful for some other customers as well.

-
Michael Geddes commented
The TDBXError that is being raised only has a limited number of integer codes, and then you are relying on parsing language specific errors.
The 2 that we have problems with are duplicate key errors and deadlock errors. The integer error codes for these are both -1. There is no Inner Exception in this case to get further information from -
Alexander Somov commented
It's not necessary because it's already available. You can check the class of the retrieved exception object. The general exception class, EUniError, has fields ErrorCode and InnerError. If InnerError class is EPgError, then you can retrieve the DetailMsg property.