Print

Print


On Wed, Mar 6, 2013 at 6:30 PM, Matt L. Miller <[log in to unmask]> wrote:
While I was doing some failure-mode testing on some code that uses GeoMASON,
I have noticed that ShapeFileImporter.read(URL, GeomVectorField, Bag, Class)
has a problem with its exception handling.

The method declares that it throws a FileNotFoundException; however, it
actually never does so -- the entire IO section is surrounded in a try ...

Actually, it does throw a FileNotFoundException:

    250         try
    251         {
    252             FileInputStream shpFileInputStream = new FileInputStream(shpFile.getFile());
    253 
    254             if (shpFileInputStream == null)
    255             {
    256                 throw new FileNotFoundException(shpFile.getFile());
    257             }

 
catch that catches all IOExceptions and prints an error message, but does
NOT propagate the exception back up to the caller. Thus, you get an error
message on STDERR, but then your code continues blithely along.

I would recommend either adding a

throw e;


You're right.  It's bad form to catch exceptions without propagating them.  I've committed changes whereby the exceptions are rethrown with appropriate changes to the function signatures.