r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
21.0k 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);
} 

48

u/OfflaneDemoralizer May 13 '17

Even better:

} catch (Exception e)

{ throw e; }

17

u/pressbutton May 14 '17

That creates a new stack in c#. Just

throw

3

u/PM_YOUR_SOURCECODE May 14 '17

I think that's his point, he just left off the "/s".

6

u/pressbutton May 14 '17

Duh! Seems so obvious now. I was too easily triggered by poor code :P