-
When I run a batch script using a GDAL/OGR program, I can detect if an error occured by checking
ERRORLEVEL
for the value 1. -
When using GDAL/OGR in python or .NET, I get an exception when an error occurs.
Question:
How do I detect if a Warning
was issued during the execution?
Why?
Even though a process can execute to the end despite of warnings, the output might be corrupt with respect to the data I expect. You could argue that I ought to check for these corruptions, but since I have control of the entire process, I would like to be able to stop when a warning is issued.
Best Answer
If using GDAL 1.10+ the python bindings allow you to specify a python callable as an error handler. However, these error handlers appear to be called in a separate thread and any exceptions raised do not propagate back to the main thread. So something like this won't work:
But you can do something like this: