I'm currently using a very simple MVC framework, Bear Bibeault's Front Man, which, for those not familiar, is pretty similar to Spring MVC (in concept at least). One of the issues I'm having is how to handle exceptions properly.
I am currently doing something like this,
try {
//do something
}catch (Exception ex) {
logger.error("Logging error", ex);
Map model = new HashMap();
model.put("error", ex.getLocalizedMessage());
cc.setScopedVariable("model", model);
cc.forwardToView(ERROR_VIEW);
}
Essentially I log the exception and then forward to an error view page.
However this strikes me as not being the right way to do this. It results in a lot of boilerplate code that isn't very DRY.
What is a better way to handle/log exceptions in a web application?