[gdal-dev] Lost error messages
Ray at Daylon
rayg at daylongraphics.com
Tue Jan 30 18:44:38 PST 2024
Evan,
On 1/30/2024 3:26 AM, Even Rouault wrote:
> Ray,
>
> Le 30/01/2024 à 05:43, Ray at Daylon via gdal-dev a écrit :
>> I was tracing through the TIGER/Line OGR driver and noticed that
>> it calls OGRTigerDataSource::Open with the bTestOpen parameter
>> set to TRUE, causing that function to skip calling CPLError
>> and only return FALSE if an error happens.
>>
>> This causes an interesting situation: an app can have the TIGER driver
>> fail, but not be told why. Calling CPLGetLastErrorXXX doesn't help
>> because no error condition was formally reported.
>>
>> Is there a reason why bTestOpen is set to TRUE? Shouldn't
>> full error reporting be the default? If this parameter is
>> important, shouldn't it be part of the driver API so an app
>> can set it to get errors described?
>
> I presume this is mostly a copy&paste pattern borrowed from the
> Shapefile driver. Basically the reason to be silent in most situations
> is that the Tiger driver opens a directory, and there's no easy way to
> know in advance if a directory belongs to the Tiger driver, or the
> Shapefile one, or the MITAB one, or etc.. than iterating over its files
> and checking if they have extensions that look like a Tiger dataset. So
> failure of finding such file shouldn't trigger a verbose error,
> otherwise this would prevent other drivers to also try checking if they
> recognize the content of the directory.
>
> And congratulations: you're the first user in recent times I'm aware of
> to have interest in that driver ;-) Or perhaps that was just accidental?
>
> Even
>
Thanks. My interest was that TIGER is a supported format in Leveller, so
I need to ensure the user experience for error reporting is valid. What
happened was that when Leveller starts, it loads up some UI textures
that are in TIFF format, but because those files have unsorted tags, the
TIFF driver calls CPLError with a warning about unsorted TIFF directories.
Then, when one goes to import a TIGER dataset and there's a read error,
the TIGER driver returns FALSE w/o calling CPLError, and Leveller calls
CPLGetLastError which returns the earlier TIFF warning, which is of
course of no help at this point. If the TIFF textures had been okay,
then there'd be no error text at all, which would be equally unhelpful.
From what you explained, it seems like the TIGER (and NTF) dataset open
logic tried to solve a problem at the wrong place -- it is nice to have
apps that can try different drivers to figure out a dataset format on
their own, but the driver shouldn't hide error messages on the app's
behalf, and it shouldn't output error messages (to console, e.g.) on its
behalf either. The latter can be fixed using the existing hook API, but
the message hiding still needs to be addressed. Maybe add a "Hide errors
when opening" driver API and default it to true in the TIGER and NTF
drivers to preserve the existing behavior?
(There may be other drivers with the same problem; I haven't had time to
do an exhaustive check).
Ray
More information about the gdal-dev
mailing list