Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Even Rouault
> Even, > > Yes, you are right. I missed you mean the CPLError. In case of custom > throwing handler it will jump out of the context. I do throw exceptions > reacting on GDAL errors, but not from within GDAL internal context, > like the custom handler. Yes, of course you are free to emit C++ exce

Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Mateusz Loskot
Even Rouault wrote: > Mateusz Loskot wrote: >> This is interesting. Could you give example? >> How is checking if GDALOpen returned NULL and prematurely exiting >> different to throwing exception? > > The ::Open() method of GDAL drivers is supposed to make all necessary > cleanups, even in case of

Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Even Rouault
> This is interesting. Could you give example? > How is checking if GDALOpen returned NULL and prematurely exiting > different to throwing exception? Mateusz, The ::Open() method of GDAL drivers is supposed to make all necessary cleanups, even in case of errors, before returning NULL. But if yo

Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Mateusz Loskot
Even Rouault wrote: > Le mercredi 06 avril 2011 18:09:42, Howard Butler a écrit : >> You need to implement your own error handler if you want GDAL to throw >> exceptions when it can open something. > > I would recommand *against* doing that. Throwing exceptions from the GDAL > error handler can lea

Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Even Rouault
Le mercredi 06 avril 2011 18:09:42, Howard Butler a écrit : > On Apr 6, 2011, at 11:04 AM, canduc17 wrote: > > I have this incorrect code: > > try > > > > { > > myDataset = (GDALDataset *) GDALOpen( "myimg", GA_ReadOnly ); > > } > > catch(int n) > > { > > > > c

Re: [gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread Howard Butler
On Apr 6, 2011, at 11:04 AM, canduc17 wrote: > I have this incorrect code: > try > { > myDataset = (GDALDataset *) GDALOpen( "myimg", GA_ReadOnly ); > } > catch(int n) > { > cout << "File not existent!" << endl; >return 14; > } >

[gdal-dev] Catch a GDALOpen exception

2011-04-06 Thread canduc17
I have this incorrect code: try { myDataset = (GDALDataset *) GDALOpen( "myimg", GA_ReadOnly ); } catch(int n) { cout << "File not existent!" << endl; return 14; } I would like to catch the exception thrown by GDALOpe