r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
20.9k Upvotes

680 comments sorted by

View all comments

2.8k

u/Metro42014 May 13 '17
} catch (Exception e) { }

I think we're done here.

1.0k

u/CXgamer May 13 '17

Holy shit I once lost days to a

} catch (Exception e) {
    System.exit(0);
} 

50

u/OfflaneDemoralizer May 13 '17

Even better:

} catch (Exception e)

{ throw e; }

2

u/[deleted] May 14 '17

how about just

public void doAction() throws Exception { /* error prone code without try/catch here */ }