28

found this in our codebase today

try {
//do something
} catch () {
try {
//do something else
} catch () {
try {
//do something else else... this goes on 4-5 levels deep
} catch () {
//log... couldn't do
}
}
}

Comments
  • 7
    Somebody took the saying way too seriously...
    "Try try try again"!!
  • 5
    Exception handling should not be used for flow control.
  • 1
    > why use if else if we have exceptions

    In some cases actually using exceptions is better than if else. Python recommends it in a lot of places
  • 1
    Wat?
    why no use functions?
  • 0
    It makes to have exception flows, except I would stop at level 2
  • 2
    I hate the misuse of exceptions. Some of my collegues would use them for everything.
    Following their logic, it would be ok for an IsEmpty() method to throw an exception for the case that the list not empty. 😞
  • 4
    I feel bad for that last catch block. It feel like someone gave up on the dream of bulletproof code.
  • 1
  • 0
    For me try is only use on IO using data
Add Comment