[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ptp-dev] Empty catch in RangeSet constructor
|
Good idea.
Greg
On Jun 10, 2008, at 3:21 PM, Daniel Felix Ferber wrote:
Hi,
The org.eclipse.ptp.core.util.RangeSet constructor with string
parameter contains two empty catch blocks. This was preventing me to
identify an bug where the RangeSet was being instantiated with an
invalid number as a machine ID.
Is there a special reason to swallow NumberFormatExceptions? If not,
I wouldn't it make sense to log the error or to propagate/rethrow
the exception as a RuntimeException?
Here is the code:
public RangeSet(String str) {
if (str != null) {
String[] ranges = str.split(",");
for (String range : ranges) {
String[] vals = range.split("-");
if (vals.length == 1) {
try {
add(Integer.parseInt(vals[0]));
} catch (NumberFormatException e) {
}
} else {
try {
add(Integer.parseInt(vals[0]),
Integer.parseInt(vals[1]));
} catch (NumberFormatException e) {
} }
}
}
}
Best regards,
Daniel Felix Ferber
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev