I have a very basic question about best practice of using try
/catch
.
I have a simple function (DAO) like this
public void addVehicl
You should only catch those exceptions which you want to handle. You may include a topmost exception handler to turn any unhandled exceptions into something somewhat useful for the end user.
Instead of e.printStackTrace();
, try return proper exception message.
find out more about exception handling here
Here is more discussion about exception handling.