Write your own exception handler and attach it to the Application.OnException event. If an OnException event handler is present, the application will not use the default MessageBox default procedure. A signature is defined as:
TExceptionEvent = procedure (Sender: TObject; E: Exception) of object;
If this is a server, you will probably want to write the exception information to the log and possibly return some error to the user.
source share