[Gdal-dev] SWIG Exceptions for C# Bindings
szekerest at gmail.com
Fri Mar 16 10:34:12 EDT 2007
It depends on the implementation in the gdal core whether the CPLError
is invoked or not. Generally if we can retrieve the error by calling
CPLGetLastErrorType() the error will be propagated to C# as an
As far as I can see the various providers are not calling CPLError in
DataSource.GetLayerByIndex. Here is a common example of it:
OGRLayer *OGRPGDataSource::GetLayer( int iLayer )
if( iLayer < 0 || iLayer >= nLayers )
Therefore you should always check the return value in this case.
2007/3/16, Simon Perkins <sy at perkins.net>:
> Can someone remind me how error reporting works with the GDAL and OGR C#
> bindings? Do errors typically throw exceptions, or return status codes,
> or nulls, or both? There seems to be code to throw exceptions in most of
> the method definitions, but the code in swig/csharp/apps often appears
> to be checking for return null values instead. Which is correct?
> For instance, if OGR.DataSource.GetLayerByIndex() is invoked with an
> invalid index, or if something else goes wrong, do we always/sometimes
> get an exception or do we just get a null back? Is there a general policy?
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
More information about the Gdal-dev