Poor error messages in otbImageFileReader.hxx
As the problem is the consequence of design choices, I don't directly provide a MR.
When the filereader cannot open a file, we only observe in
|| 12: terminate called after throwing an instance of 'otb::ImageFileReaderException' || 12: what(): /build/path/otb/Modules/IO/ImageIO/include/otbImageFileReader.hxx:604: || 12: The file does not exist.
It doesn't help to know what is that damn file that doesn't exist.
Roots of the problem
OTB has a complex exception class hierarchy. Some child classes store more information in dedicated fields. Here in
ImageFileReaderEception the missing information is the
Alas what really matters in the end is the standard message returned by
std::exception::what(). While extra fields could be exploited locally, if they aren't used in the
what(), they don't serve any purpose.
What I recommand in the short run is to follow the Open Close Principle and to avoid adding cases and cases of specific situations that need to be taken care of differently in interminable series of
Even if we still maintain multiple exceptions classes,
what()shall contain all the pertinent information that the end-user needs
"the file foobar doesn't exist"or
"you are not authorised to open foobar file".
The best way (to have nice English messages) is to change the text used to create
In the long run, do we really need that many different exception types? Isn't it complicating the situation?