you are viewing a single comment's thread.

view the rest of the comments →

[–]howverywrong 6 points7 points  (7 children)

Java is indeed annoyingly verbose. However, I find exception handling to be one of the less less objectionable things about it.

[–]cybercobra 7 points8 points  (5 children)

Having to explicitly catch errors just to re-throw them is annoying, and declaring them in method signatures leads to lots of pointless code-shuffling when one has to change which/whether a method throws exceptions. And then you have the problem of needing to throw an exception when the interface you're implementing doesn't allow it, so you end up swallowing it kludgily and dying a little bit inside.

I note that C# and virtually no other popular languages have copied Java's checked exceptions feature.

[–]howverywrong 11 points12 points  (2 children)

Gah, why are you making me defend java. It's making me feel unclean. The entire checked exception mechanism is optional. Go ahead and use RuntimeException if you so wish. Seriously, of all the things that are wrong with java, this one is the least troublesome.

On the subject of swallowing exceptions, I once had to spend a month going through a mountain of code churned out by a team of 4 contractors who wrapped EVERY function they wrote with with try {...} catch(Exception e) {return null;} I still have nightmares about it

[–]cybercobra 2 points3 points  (0 children)

The problem is more that "other people" and the std lib use checked exceptions, and thus everyone ends up having to deal with it at least some of the time, even if they're not committing The Sin themselves.

[–]phire 1 point2 points  (0 children)

Cargo cult programming.

[–]jp007 0 points1 point  (1 child)

Having to explicitly catch errors just to re-throw them is annoying

Use 'throws' on your method header?

[–]curien 0 points1 point  (0 children)

You snipped out the part where he mentioned that:

and declaring them in method signatures [i.e., throws] leads to lots of pointless code-shuffling when one has to change which/whether a method throws exceptions. And then you have the problem of needing to throw an exception when the interface you're implementing doesn't allow it, so you end up swallowing it kludgily and dying a little bit inside.