Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32251 closed Uncategorized (invalid)

GEOSGeometry error logging when handling a GEOSException

Reported by: Richard Boon Owned by: nobody
Component: GIS Version: 3.1
Severity: Normal Keywords: GEOSGeometry GEOSException logger
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (2)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

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.

comment:2 by Mariusz Felisiak, 3 years ago

See docs.

Note: See TracTickets for help on using tickets.
Back to Top