[gdal-dev] ogr.UseExceptions() doesn't raise an exception on
a non-existant dataset [SEC=UNCLASSIFIED]
Ari Jolma
ari.jolma at gmail.com
Thu Oct 21 01:59:46 EDT 2010
On 10/21/2010 04:58 AM, Pinner, Luke wrote:
> OGR doesn't raise an exception on attempting to open a non-existant
> dataset even if ogr.UseExceptions() has been called, GDAL does though.
> Is this intentional or a bug?
>
Luke,
It is a (bit annoying feature admittedly) feature. If none of the
available drivers open a data source based on the passed string, then
OGROpen returns a null and barks only to debug stream if one is open.
The swig wrappers (you're using Python swig wrappers) does not test this
condition (no error but data source object null) and pass the null
object up. So it is the app developer's responsibility to check for the
returned data source object.
Best regards,
Ari
> GDAL version = 1.7.2
>
> from osgeo import gdal,ogr
> gdal.UseExceptions()
> ogr.UseExceptions()
>
> ds=ogr.Open('foo')
> #No exception raised by ogr
>
> ds=gdal.Open('foo')
> Traceback (most recent call last):
> File "<interactive input>", line 1, in<module>
> RuntimeError: `foo' does not exist in the file system,
> and is not recognised as a supported dataset name.
>
> Regards
> Luke
>
> If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments.
>
> Please consider the environment before printing this email.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
More information about the gdal-dev
mailing list