Regarding Error messeges, postgresql manual says:
Note: When specifying an error code by SQLSTATE code, you are not limited to the predefined error codes, but can select any error code consisting of five digits and/or upper-case ASCII letters, other than 00000. It is recommended that you avoid throwing error codes that end in three zeroes, because these are category codes and can only be trapped by trapping the whole category.
What are these category codes? In what case they are good use?
Here is the list of error codes: Appendix A. PostgreSQL Error Codes
Error codes can be used for exception handling. And category codes are useful when you don't really care which exactly exception had been thrown as long as it is belong to a category. For example:
$$
BEGIN
...
EXCEPTION WHEN integrity_constraint_violation THEN
...
END
$$
In this case you will catch all exceptions that belong to integrity_constraint_violation category: foreign_key_violation, check_violation, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With