Figure 4. Let SharePoint Handle Error Messages.
SharePoint handles its own error messages—and yours. If the user enters an invalid value, you can throw a WebPartPageUserException exception and pass it the text to display near the problem control.