openmicroscopy/bioformats — pull request #691 by ctrueden (2013-09-05 17:29:01+00:00)
Title: ND2 defensive parsing

This change is an attempted fix for [Fiji bug #655](http://fiji.sc/bugzilla/show_bug.cgi?id=655).

Several numerical parsing methods throw `NumberFormatException` when the input string is not actually a number. In particular:

* `Integer.parseInt(String)`
* `Double.parseDouble(String)`
* `new Integer(String)`
* `new Double(String)`

The ND2 handler parses a large number of string key/value pairs, converting values into numbers in many cases. But in almost every case, no error handling was done in case the input value was not a number.

This change adds a blanket try/catch for `NumberFormatException` around areas that parse lots of numbers, emitting a warning for any non-conforming key/value pairs. This allows parsing to continue, hopefully resulting in a less fragile ND2 reader.

Note that this change is nearly all whitespace indentation; the easiest way to view the "real" change is using `git show -b` on the commit.