return more than one error messages
It's a shortcoming of using Exception. we can only return one exception with one error message.
However, sometimes, we need more. For instance, when we are doing a validtion of a form, we may return a list of errors like:
name should be entered; password doesn't match and etc.
It's better return a list, rather than return one each time. coz that will be time consuming and annoying.
The solution is extend the standard Exception class (of course RuntimeException, see my another blog), add a list property to the Exception. So you can easily add new error message key by exception.addError(message), or something like that.
Of course, you need to parse it when you catch such kind of exception.