From acfc49ed4e3c1920b0fd71a7124e688eb2002a1b Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Wed, 4 Jun 2008 17:24:08 +0000 Subject: [PATCH] gis: gdal: Made error message when opening an invalid `DataSource` more clear. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7571 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/gdal/datasource.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py index 0cc757d7a5..02363a075b 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -72,9 +72,13 @@ class DataSource(object): if isinstance(ds_input, basestring): # The data source driver is a void pointer. ds_driver = c_void_p() - - # OGROpen will auto-detect the data source type. - ds = open_ds(ds_input, self._write, byref(ds_driver)) + try: + # OGROpen will auto-detect the data source type. + ds = open_ds(ds_input, self._write, byref(ds_driver)) + except OGRException: + # Making the error message more clear rather than something + # like "Invalid pointer returned from OGROpen". + raise OGRException('Could not open the datasource at "%s"' % ds_input) elif isinstance(ds_input, c_void_p) and isinstance(ds_driver, c_void_p): ds = ds_input else: