"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Would it be possible to do a command line app?
>
> bash$ pg_error 1200D
> Severity: ERROR
> Message: Division by zero
> Detail:
> Hint: Modify statement to prevent zeros appearing in denominators.
You're assuming that there's a one-to-one mapping of error codes to
messages, which is not likely to be the case --- for example, all the
"can't happen" errors will probably get lumped together under a single
"internal error" error code. You could provide a lookup of the
spec-defined meaning of each error code, maybe.
>> Is there any benefit to having this over just including an index of
>> error codes in the documentation?
> It's quick and easy, especially when there's thousands of error codes.
But there aren't. I count about 130 SQLSTATEs defined by the spec.
Undoubtedly we'll make more for Postgres-specific errors, but not
hundreds more. There's just not value to applications in distinguishing
errors at such a fine grain.
regards, tom lane