In my application there is a custom exception (extending RuntimeException
) which I have created for situations like this. When this kind of exception has been thrown. the client will display the message to the user in an error dialog. All other exceptions cause a generic dialog to be displayed, with Details button, which allows the user to see the stacktrace and send it to me. I don't think Java contains any exception type suitable for this, so you have to create your own.
However, I completely agree with the other answers on that the user interface should prevent so called "user mistakes". Preventing errors is one of the basic rules of usability. If the user selects too many items, the client should validate that, display it in a meaningful way and not throw an exception. In my application the special exception type is only for cases where the UI couldn't validate the data properly before sending it to the server. Actually getting the custom exception is now very rare.