Hacker News new | past | comments | ask | show | jobs | submit login

Just write your Java code without a try/catch block anywhere

The point of checked exceptions is that you can’t do that. It is a compile-time error to not either catch the exception or explicitly indicate that you will propagate it.

Unfortunately, at least in Java, that style proved too onerous for a lot of programmers and motivated the catch-all, do-nothing wrapper idiom that is completely unhelpful as far as safety goes.

Exceptions don't stop programmers from doing anything.

At least in principle, you can statically detect any failures to handle possible exceptions if you have a suitable type system. Of course, if you just hack around those warnings, as we’ve seen Java programmers do with checked exceptions and catch-alls, then you’re no better off than if you ignored a relevant return code in the first place (aside, perhaps, from making it much more obvious to a static analyser or during a code review that you are doing so).




> > Just write your Java code without a try/catch block anywhere

> The point of checked exceptions is that you can’t do that.

Sure you can. You just have to write "throws Exception" after all your function signatures.


That would be a (perhaps rather foolish) variation of the “explicitly indicate that you will propagate it” case.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: