No problem, I do check the returned data source object. I just thought it inconsistent with GDAL.
Thanks for the reply, Luke -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Ari Jolma Sent: Thursday, 21 October 2010 5:00 PM To: [email protected] Subject: Re: [gdal-dev] ogr.UseExceptions() doesn't raise an exception ona non-existant dataset 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 > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev 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 [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
