Source code for shapelib.exceptions.geometries_exceptions
[docs]
class InvalidGeometryError(Exception):
"""
Exception raised when invalid geometries cannot be validated or fixed.
This error is raised when a geometry, such as a shapefile or GeoDataFrame geometry,
is found to be invalid and cannot be corrected using the available validation methods
(e.g., `make_valid` in Geopandas or Shapely).
Attributes
----------
message : str
The error message describing the nature of the invalid geometry.
Examples
--------
>>> if not geometry.is_valid:
>>> raise InvalidGeometryError("The geometry is invalid and cannot be fixed.")
"""
def __init__(self, message: str = "Invalid geometry could not be validated or fixed."):
"""
Initialize the InvalidGeometryError with a custom message.
Parameters
----------
message : str, optional
The error message to display. Defaults to a general validation error message.
"""
super().__init__(message)