[postgis-users] Programmatically identify PostGIS errors?

P O'Toole P.OToole at uwyo.edu
Wed Feb 8 18:06:40 PST 2017



>My app allows users to write their own SQL, and I'd like to show them all
>error messages directly pertaining to their query, while hiding system
>errors, etc. It seems that all PostGIS errors, however, have the same
>generic error code: XX000 Internal Error. For example:

>SQLSTATE[XX000]: Internal error: 7 ERROR:  Operation on mixed SRID

>Is there a way to identify an error as coming from PostGIS, other than
>assuming that all internal errors are from PostGIS?

I'm not sure there's a separate, formally-maintained list of all PostGIS errors your users might encounter. Your best bet is probably to look at the PostGIS source and see how errors are being generated there. They may or may not all be neatly collected in one place as opposed to being constructed on-the-fly. Either way, you should be able to generate a list of error-message formats for your installed version of PostGIS and add some handling logic in your application when it looks like something from PostGIS is bubbling.

- Patrick O'Toole

Application Developer
Wyoming Natural Diversity Database
UW Berry Biodiversity Conservation Center
Department 3381, 1000 E. University Av.
Laramie, WY 82071
P: 307-766-3018

More information about the postgis-users mailing list