Are there any guidelines on exception propagation in Java?
When do you add an exception to the method signature? For example: if an exception is only thrown when an
Guidelines that have helped me in the past include:
You should handle the method as soon as possible, but it must make sense. If the exception doesn't make sense to be thrown by your method, but you can't handle it, wrap it into another exception and throw this new exception.
A bad practice about exception is to catch them all (it's not pokemon, it's java !) so avoid catch(Exception e)
or worse catch(Throwable t)
.