36

Just found this piece of code from one of my coworkers:

restMethod() {
try {
// some complicated logic
} catch (WebApplicationException e) {
throw e;
}
}

Why?!

And btw: Hi fellow devRant ppl! 👋

Comments
  • 1
    Maybe he initially planned to log it here before rethrowing.
  • 0
    @danglingPtr yeah maybe. Usually you could use this for logging or for rollbacks in the EntityManager
  • 0
    I've seen this, and in most cases it was a placeholder for a to-do: throw another exception from the current namespace (and perhaps log this one)

    This try-catch is redundant, though.
  • 1
    I use try catch and then throw just to cleanup for the exception, log every important thing then throw
  • 0
    Ah. The old rethrow and discard stack trace gambit.
  • 0
    lmao, I bet one day this motherfucker will be catching StackOverflowException
Add Comment