[gdal-dev] OGR error handling

Andre Vautour andre.vautour at caris.com
Tue Oct 20 12:20:58 PDT 2015


Hi all,

We are using OGRSFDriver::CopyDataSource() to copy a GML data source to a memory data source on v1.11.x.

We have encountered a problem where one of the feature tags of a particular GML file we are trying to read is malformed. What we are seeing is that an error occurs in OGRGMLLayer::GetNextFeature(), which gets reported as expected via CPLError().

The problem we are faced with is that that error seems to be reset using CPLErrorReset() before control returns to the caller of CopyDataSource(), specifically in OGRDataSource::CopyLayer(). The result is that the copying silently skips over problematic features.


Is that the expected behavior of copying a data source? Given that GDAL isn't necessarily exception safe, we've typically used CPLGetLastErrorNo after control returns to get at such errors that occur in functions that do not return an error directly in the method signature. Is there a better approach to error handling that we could/should be using?

Thanks,
André



More information about the gdal-dev mailing list