summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2017-09-02 08:38:17 +0100
committerTim Graham <timograham@gmail.com>2017-09-04 19:00:32 -0400
commit66657eb01f36081f33d847390e4f7034ff3e9f52 (patch)
treee02a4d4ed4705516fd18ae5429cff0839c7f5654 /django
parent0d9e1163e897d8e43a3e018938a58131efcbc135 (diff)
Improved messages in IndexErrors raised by GDAL objects.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/gdal/datasource.py4
-rw-r--r--django/contrib/gis/gdal/feature.py4
-rw-r--r--django/contrib/gis/gdal/geometries.py6
3 files changed, 7 insertions, 7 deletions
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 9890a5ab51..d3009c234f 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -89,12 +89,12 @@ class DataSource(GDALBase):
if isinstance(index, str):
layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
if not layer:
- raise IndexError('invalid OGR Layer name given: "%s"' % index)
+ raise IndexError('Invalid OGR layer name given: %s.' % index)
elif isinstance(index, int):
if 0 <= index < self.layer_count:
layer = capi.get_layer(self._ptr, index)
else:
- raise IndexError('index out of range')
+ raise IndexError('Index out of range when accessing layers in a datasource: %s.' % index)
else:
raise TypeError('Invalid index type: %s' % type(index))
return Layer(layer, self)
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index 9a398803fe..db8c981312 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -38,7 +38,7 @@ class Feature(GDALBase):
elif 0 <= index < self.num_fields:
i = index
else:
- raise IndexError('index out of range')
+ raise IndexError('Index out of range when accessing field in a feature: %s.' % index)
return Field(self, i)
def __len__(self):
@@ -111,5 +111,5 @@ class Feature(GDALBase):
"Return the index of the given field name."
i = capi.get_field_index(self.ptr, force_bytes(field_name))
if i < 0:
- raise IndexError('invalid OFT field name given: "%s"' % field_name)
+ raise IndexError('Invalid OFT field name given: %s.' % field_name)
return i
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index f2ca1345ed..7b304d9af0 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -564,7 +564,7 @@ class LineString(OGRGeometry):
elif dim == 3:
return (x.value, y.value, z.value)
else:
- raise IndexError('index out of range: %s' % index)
+ raise IndexError('Index out of range when accessing points of a line string: %s.' % index)
def __len__(self):
"Return the number of points in the LineString."
@@ -616,7 +616,7 @@ class Polygon(OGRGeometry):
if 0 <= index < self.geom_count:
return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
else:
- raise IndexError('index out of range: %s' % index)
+ raise IndexError('Index out of range when accessing rings of a polygon: %s.' % index)
# Polygon Properties
@property
@@ -655,7 +655,7 @@ class GeometryCollection(OGRGeometry):
if 0 <= index < self.geom_count:
return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
else:
- raise IndexError('index out of range: %s' % index)
+ raise IndexError('Index out of range when accessing geometry in a collection: %s.' % index)
def __len__(self):
"Return the number of geometries in this Geometry Collection."