Is there a way to replace nested exceptions in an Errors or BindingResult object with a localized "friendly" error message?
Some info:
I do some validation in one of my domain objects to ensure that usernames don't have any fewer than 6 characters by throwing an IllegalArgumentException in the setUserName() method. I'm aware of the Validator interface, which I use for other of my domain objects but it wasn't appropriate in this case.
On the web side of things, when a new user is created with a username fewer than 6 characters, the following appears in my <form:errors />
While I'm happy that the exception is associated with the appropriate field and included in the Errors object, this isn't very helpful for an end user. Is there a way to "trap" this error and replace it with a friendlier, localized error?Code:Property username threw exception; nested exception is java.lang.IllegalArgumentException: A username must contain at least six characters.


Reply With Quote
