Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom error code class range in PostgreSql?

The PostgreSql documentation does not seem to mention a special class range for custom error codes. Has any been defined or is there an unofficial agreement on a specific class range?

like image 690
Jérôme Verstrynge Avatar asked Mar 23 '14 17:03

Jérôme Verstrynge


1 Answers

At the bottom of the first section on this page there is some oblique, and indeed rather unspecific, reference to custom error codes. My approach for custom error codes:

  • Start with a capital letter but not F (predefined config file errors), H (fdw), P (PL/pgSQL) or X (internal).
  • Do not use 0 (zero) or P in the 3rd column. Predefined error codes use these commonly.
  • Use a capital letter in the 4th position. No predefined error codes have this.

As an example, start with a character for your app: "T". Then a two-char error class: "3G". Then a sequential code "A0"-"A9", "B0"-"B9", etc. Yields T3GA0, T3GA1, etc.

But as Craig Ringer indicated in his comment to the OP, some better guidance on the topic might be useful. Keep in mind though that such guidance would hardly solve the issue, unless a global registry is made of error ranges for common extensions. I am doubtful that such a registry will be made, however.

like image 90
Patrick Avatar answered Sep 20 '22 18:09

Patrick