In domain model of my web application I've an entity Foo which can be created only by a pojo FooBean:
Foo.newInstance(FooBean fooBean) (Might have been better a Builder-pattern.)
In the factory methode
newInstance() the pojo FooBean is validated and throws NullPointerExceptions and IllegalArgumentExceptions if needed. The fields of the pojo are filled by a form on the presentation layer. That form does some validation on the user input and shows user friendly messages if needed.
The exception message of the NullPointerExceptions and IllegalArgumentExceptions thrown in the
newInstance() method are rather technical and shouldn't be displayed to the end user.
What is a proper way to show user friendly error messages that are originated by the NullPointerException or the IllegalArgumentException?