- This shows how to use Eclipse to insert a try-catch block around a statement which automatically includes possible exceptions
- Select the statement to surround with a try-catch block
- Right click on the selection and choose Source -> Surround with Try / Catch Block
- You should now edit the Auto-generated catch block(s)
- Note: don't forget to remove the e.printStackTrace(); if you do not want this exception to put a stackTrace in the logs
Comments (1)
Jun 13, 2006
Antranig Basman says:
Best practice: propagate all exceptions that you don't know how to deal with as ...Best practice: propagate all exceptions that you don't know how to deal with as some kind of RuntimeException. You may choose to log them at source as well but this tends to make for somewhat noisy logs with the same exception occuring several times.
Either use JDK 1.4+ "cause" system to wrap the original exception (you will need to select an existing exception type that will fill in "cause" or derive one yourself), or, even better, use the PonderUtilCore "UniversalRuntimeException" (delivered as part of RSF!) which guarantees never to do more than one level of wrapping.
See Bruce Eckel at http://www.mindview.net/Etc/Discussions/CheckedExceptions
See URE at
http://www2.caret.cam.ac.uk/rsfwiki/Wiki.jsp?page=UniversalRuntimeException