[almighty] Analyzing Postgres Errors
Thomas Mäder
tmader at redhat.com
Wed Nov 30 09:50:08 UTC 2016
Hi folks,
Looking for the general opinion here:
As I was writing some gorm db code, I noticed that we could profit from
analyzing the error returned by db calls. In this particular case,
postgres returns "unique_violation" when trying to create a second
project with the same name. In consequence, I could return
"BadParameter" instead of just "internal error". Unfortunately, these
structured errors are entirely specific to postgres. We'd have to cast
down to a postgres error struct to get the info.
Do you think it would be generally a good idea to do this in our db
access code?
/Thomas
More information about the almighty-public
mailing list