Adding a try-catch block

  • This shows how to use Eclipse to insert a try-catch block around a statement which automatically includes possible exceptions
  1. Select the statement to surround with a try-catch block
  2. Right click on the selection and choose Source -> Surround with Try / Catch Block
  3. 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