[Django] #32251: GEOSGeometry error logging when handling a GEOSException

5 views
Skip to first unread message

Django

unread,
Dec 9, 2020, 5:17:55 AM12/9/20
to django-...@googlegroups.com
#32251: GEOSGeometry error logging when handling a GEOSException
-------------------------------------+-------------------------------------
Reporter: Richard | Owner: nobody
Boon |
Type: | Status: new
Uncategorized |
Component: GIS | Version: 3.1
Severity: Normal | Keywords: GEOSGeometry
Triage Stage: | GEOSException logger
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When instantiating an invalid GEOSGeometry and catching the GEOSException,
the logger still logs a GEOSException. I would expect no error logging
when catching and handling the exception.
For example:

{{{
from django.contrib.gis.geos import GEOSGeometry, GEOSException
import logging

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

try:
GEOSGeometry("POLYGON ((20 30, 35 35, 30 20))")
except GEOSException:
pass
}}}

This will display the following error message:

`2020-12-09 10:03 ERROR GEOS_ERROR: IllegalArgumentException: Points of
LinearRing do not form a closed linestring`

It seems that the logging happens here:
https://github.com/django/django/blob/2c5d6dc44779448de1497f32c925c96975fae461/django/contrib/gis/geos/libgeos.py#L99

--
Ticket URL: <https://code.djangoproject.com/ticket/32251>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 9, 2020, 5:40:12 AM12/9/20
to django-...@googlegroups.com
#32251: GEOSGeometry error logging when handling a GEOSException
-------------------------------------+-------------------------------------
Reporter: Richard Boon | Owner: nobody
Type: Uncategorized | Status: closed
Component: GIS | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: GEOSGeometry | Triage Stage:
GEOSException logger | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

These errors are logged before exceptions are caught. It's not feasible to
recognize in Django that they're handled in you app. You can try to add
your own filter to the logger.

--
Ticket URL: <https://code.djangoproject.com/ticket/32251#comment:1>

Django

unread,
Dec 9, 2020, 5:43:47 AM12/9/20
to django-...@googlegroups.com
#32251: GEOSGeometry error logging when handling a GEOSException
-------------------------------------+-------------------------------------
Reporter: Richard Boon | Owner: nobody
Type: Uncategorized | Status: closed
Component: GIS | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: GEOSGeometry | Triage Stage:
GEOSException logger | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

See [https://docs.djangoproject.com/en/3.1/topics/logging/#id5 docs].

--
Ticket URL: <https://code.djangoproject.com/ticket/32251#comment:2>

Reply all
Reply to author
Forward
0 new messages