[ogr2ogr][vrt] Do not return 0 on errors in the VRT#14839
Conversation
Fix OSGeo#14826 Check if there were errors opening the VRT and error out if that happens. Also catch errors from write alg
4a1587b to
04f8b46
Compare
| bChangeGeomType, eType, m_overrideCrs, | ||
| m_layerMetadata, m_unsetLayerMetadata, | ||
| m_unsetFID)); | ||
| if (CPLGetErrorCounter() != errorCount) |
There was a problem hiding this comment.
Would this convert warnings into failures? It looks like CPLErrorV increments the error counter whenever it is called, regardless of the error type?
There was a problem hiding this comment.
Good catch. I missed during review that GDALVectorEditAlgorithmLayer() constrructor emits warnings. We should indeed restrict the before/after check just around oSrcLayer.GetLayerDefn()
There was a problem hiding this comment.
What about a static std::unique_ptr<GDALVectorEditAlgorithmLayer>::Create that would return a nullptr on construction failure, allowing us to use conventional return code error propagation?
Or GetLayerDefn() returning nullptr on failure?
There was a problem hiding this comment.
Or
GetLayerDefn()returningnullptron failure?
Actually that was my first attempt but after a conversation with @rouault we decided that GDAL source code is not ready for GetLayerDefn() returning nullptr on failure.
I'll check the alternatives.
Fix #14826
Check if there were errors opening the VRT and error out if that happens.