Hello,
Using PB 2017 R3, Postgresql 11
Want to display better error message(s) to users, when error(s) returned by database. All users can't understand message(s) like Primary key violation, check constraint error, Unique key violation etc..
Currently I used to display the error message and error code, returned by the database. It starts with
SQLState = P0001
ERROR: Partially Paid. Cannot Delete...; Error while executing the query;
No Changes Made to Database;
Update test_table SET Code = '100' where Code = '200'
This error message says something, as it's raised using RAISE EXCEPTION in a trigger. For Primary Key Violations, Unique Key Violation.. and for others, we may not get such messages.
How such messages could be translated that's understandable to the users?
Currently I display it in the DBError event itself. But this blocks other users, in multi-user environment, from proceeding till this messagebox is closed.
Would like to have your advice regarding the displaying the error messages in a better way and the place (event) where it could be displayed.
Happiness Always
BKR Sivaprakash
1) Display a more friendly user message like "A database error has occurred. Please contact application support".
2) Log the actual DB error number and message to an Application log file
3) Allow the user to decide the flow ... "Continue Yes/No?".
4) Suppress the DB Error event like Marco suggests.
Will a general message be sufficient ? Won't it be better to have a message that describes the error ?
Well, I would like to know where / when this error could be displayed ? Say if user A is getting is this error and we display the message at DB error Event, user B and C could get locked, if they get some / same DB error. This lock is there till user A dismisses the error message.
Since the whole things being in a transaction, with Autocommit set to False, as neither commit or rollback happens at DB error event, other users need to wait.
Would like to know whether this wait could be avoided, by placing this information in any other (better) event ?
Yes currently those messages get displayed at DB error event only. Searching a better place to avoid the locking in some circumstances.