Ah, it was people like you who did this even when, as you said it should never happen, that caused me many a late night... 'cause it did and that empty catch block hid it.
Don't leave empty catch blocks. At least put in some form of logging of the exception, just in case.
Re:Don’t Use Try/Catch (2010)
by Mindless2112 on Saturday December 28, 2013 @01:39PM
(#6975714)
The most common code I write in C# is in switches on enums:
default:
throw new InvalidOperationException("Should never happen!");Why don't you just throw a runtime exception inside the catch block?
Re:Don’t Use Try/Catch (2010)
by alecdbrooks on Saturday December 28, 2013 @01:46PM
(#6975743)
My thought would be to add an assertion that always fails inside the catch block, but this probably only makes sense if you use assertions already, as they have to be turned on explicitly in Java.
Yes, I did include a "this never happens" comment. That is my favorite comment, but only if it is true.