Skip to main content
Post Made Community Wiki by Joeri Sebrechts
Source Link
Satanicpuppy
  • 6.2k
  • 26
  • 28

I use try->catch as flow control in certain situations. If your primary logic depends on something that fails, but you don't want to just throw an exception and quit...That's what a try->catch block is for. I write a lot of unmonitored server-side unix scripts, and its far far more important for them not to fail, than it is for them to fail prettily.

So try Plan A, and if Plan A dies, catch and run with Plan B...And if plan B fails, use finally to kick off Plan C, which will either fix one of the failed services in A or B, or page me.