I am working with GDAL in Python and have wanted to get GDAL to raise exceptions so that I can do something useful with them. For instance if a file cannot be opened with gdal.Open() I would like to throw an exception instead of gdal returning None. I would just like a way to capture the errors instead of them being dumped to sys.stdout.
Currently I have tried using the gdal.UseExceptions()
function but came across an issue. When gdal.UseExceptions()
is set it seems to hide certain errors and not raise an exception on them. For instance ERROR 5: Access window out of range in RasterIO() Requested (1,15) of size 25x3 on raster of 26x17
disappears and no exception is raised. This seems pretty dangerous.
Any ideas are appreciated, thanks.