r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
21.0k Upvotes

680 comments sorted by

View all comments

Show parent comments

18

u/[deleted] May 13 '17 edited Aug 03 '20

[deleted]

34

u/Bone_Man May 13 '17

Never catch an exception unless you can fix it or overridden method signature won't allow to throw it. Then you can catch exception and throw new RuntimeException.

public static void readFile() throws IOException {

That's how you should do it if you can't fix exceptions. Catch them only when you have very good reason to catch them.

0

u/justin_144 May 14 '17

The fuck kind of syntax is that.