Programmatically identify PostGIS errors?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatically identify PostGIS errors?

Joshua Chamberlain
Hello,

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 geometries

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

Thanks,
Joshua Chamberlain

_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically identify PostGIS errors?

P O'Toole
Josh

>Hello,

>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
>geometries

>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.

Cheers
- 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


_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically identify PostGIS errors?

Joshua Chamberlain
Patrick,

Thanks for your reply. I was hoping to find a less involved way, but if that's what I need to do I guess I'll do it!

Thanks so much,
Joshua Chamberlain

On Wed, Feb 8, 2017 at 6:06 PM, P O'Toole <[hidden email]> wrote:
Josh

>Hello,

>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
>geometries

>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.

Cheers
- Patrick O'Toole

Application Developer
Wyoming Natural Diversity Database
UW Berry Biodiversity Conservation Center
Department 3381, 1000 E. University Av.
Laramie, WY 82071
P: <a href="tel:307-766-3018" value="+13077663018">307-766-3018




_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users