[Insight-developers] exception swallowed
by ImageFileReader::GenerateOutputInformation()
Luis Ibanez
luis.ibanez at kitware.com
Tue Jul 10 10:04:18 EDT 2007
Hi Steve,
Fair enough...
We have now logged a bug report on this issue:
Bug #5320
http://public.kitware.com/Bug/bug.php?op=show&bugid=5320&pos=0
Looking back at the CVS logs, it seems that this
logic was added to allow some ImageIO classes to
attempt to read a file even if the file does not
exist in disk.
At this point it escapes to me why this would be
a necessary feature. Let's check with Bill before
we modify the code.
If the requirement for file existence is to be
made on an ImageIO-basis, then the method probably
should be moved to the ImageIOBase, so that it
can be overloaded by every ImageIO specialization,
and the ImageFileReader can simply delegate the
test to the ImageIO.
Thanks for pointing this out.
Luis
-------------------------
Steve M. Robbins wrote:
> Hi Luis,
>
> On Mon, Jul 09, 2007 at 07:14:44PM -0400, Luis Ibanez wrote:
>
>
>>Note however that in this case, the exception is not
>>simply "swallowed". Instead, the actual message is
>>carried along to line: 125, and then used to compose
>>a more detailed exception message in lines 131-141.
>>
>>
>>The exception is finally rethrown in lines 143-144
>>as a more specific type of Exception:
>>
>> "ImageFileReaderException"
>
>
> Yes, but only if ( m_ImageIO.IsNull() ), tested in line 120.
>
> m_ImageIO is certainly not null if the user has set it via
> SetImageIO().
>
> Even if the user has not set it, there's no documentation that leads
> one to believe that ImageIOFactory::CreateImageIO( filename, ...)
> returns null if filename doesn't exist. The implementation
> effectively calls ImageIO::CanReadFile() on all candidates and there's
> no documentation that suggests you can't simply implement
> CanReadFile() as "filename ends in .jpg" --- not that I actually found
> any such implementation.
>
>
>
>>Please let us know if you find any other suspicious code.
>
>
> I forgot to mention this earlier, but ImageFileReader::GenerateData()
> has the same try/catch block. In this case, however, the exception
> *is* well and truly swallowed: the carefully saved m_ExceptionMessage
> is never used.
>
> Cheers,
> -Steve
>
More information about the Insight-developers
mailing list