Automatic bug report sending from your application
Submitted on June 27, 2002
Many software companies develop of big projects which are still supported and advanced after the customers accept them. Both sides are interested in robust and reliability of their program. That is why, the developers perform some actions to test and find out possible errors and failures in good time. Although, there is still a probability of the critical situation appearance which is quite hard to reproduce. The situation is complicated by the fact that the end-users of the product may not know the details of its implementation. Therefore, their description of the problem can be not enough to find out and fix the reasons of the failure.
The automatic collection of the required information and automatic sending it to your special web resource by the program itself can help you solve this problem. Most developers use this technique now, including Microsoft with their new XP series and many others as well.
Let us look at the simple Delphi program which automatically collects and sends bug reports.
In the first approximation all exceptions can be split on two kinds: the first allows the program to continue running and the fatal errors after which it is impossible to go on. Distinguishing these two types, we can send the report into your support server in two different ways. This difference appears from the desire to satisfy the user necessity to go on working as soon as possible. That is why it would be nice to combine the report sending process with further user work wherever it is possible. Such feature is given to us while the continuable exceptions occur. To do that, we need the method which would allow us to work asynchronously with a remote resource. One of the easiest and cheapest ways is using the TclUploader component from the Internet Components - Clever Internet Suite library.
The own exception handler is the easiest way of catching errors. When using VCL, you can write your own one and connect it to the OnException event of the Application object. At that, the old handler should be stored if it exists.
Next, let us create a new TclUploader component and setup it on the web resource specified by you to receive bug reports.
The implementation of the DoHandleException doesn't have any difficulties and consists of filling the file being sent with the detailed information about the error and sending. When the continuable exception occurs the component is setup for asynchronous work, and it returns the control immediately. In the rest of cases the halt command, which terminates the program abnormally, is performed after the synchronous upload has done.
To display the status of uploading, it is enough to assign a hander to OnDataItemProceed event of the TclUploader component.
To test the automatic bug report sender, we can use the simple emulation of the exceptional situations. The usual "raise Exception" can be used as the continuable exception.
To reproduce another case, we approach to the real situation and try to access to invalid memory location by using the "Nil" pointer.
In conclusion, we want to note that if it is impossible to open FTP resource for users because of security, there is an ability to perform uploading by using HTTP or even HTTPS protocols. At that, the component automatically will setup itself to use the desired resource type while changing its URL property. When using HTTP protocol it should be noted that you must make an additional setup of your web server to grant the users rights to write into the specified resource.
The full version of this example can be downloaded here.
Clever Components Support Team.