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
Decide up front which set of error codes you want to handle -- and make sure PB-DB-interface + DB-driver + DBMS deliver that set of error codes!
Using SQLState for the time being requires you extract it from SQLErrText. My function is example of how one can do that.
I expect we won't see SQLState in Transaction object until PB 2019 R3 - or more probably next major version of PB.