Saving Error Messages in Text Form
by
, 19-Jul-2012 at 01:24 PM (14206 Views)
Did you know that in Windows most error messages can be converted to text using the Copy (Ctrl+C) function? This is a tremendous, yet somewhat hidden and thus underutilized, feature of Windows.
Most importantly, it works with standard Visual DataFlex errors and all messages based on the standard Windows MessageBox interface (see Message_Box, Info_Box, Stop_Box, etc. in the Visual DataFlex help index).
So, for example, if you run the Order sample workspace and try to delete a Vendor, a message box pops up asking you whether you are sure that you want to delete the record. If you click Yes, you will get an error message (provided the vendor being deleted has inventory items related to it, which all or most of the sample vendors should):
If you now press Ctrl+C on your keyboard, the whole message box is copied to the clipboard as text. If you paste it, the result looks like this:
---------------------------
Error
---------------------------
Cannot delete - related records exist
File: 21 - Vendor
---------------------------
OK
---------------------------
The main benefits of this error reporting method are:
- It is quick and easy to do
- It is smaller (in bytes) and simpler to transmit than a screenshot/image
- The information is complete and human error (typo) free
- The information is ready for copying and pasting, again without human errors, into search engines, forum searches, etc.
The above was an example of a user (handled) Visual DataFlex error message. Just as important to you as a developer are unhandled errors (see the ErrorSystem class help in the Visual DataFlex help), whether they happen to your end-users or to you during development.
For example:
If I add a button to a view that sends Request_Assign (a method of the DD class) to a view object (yes, this is a contrived sample, but it serves my purpose) and click on that button, I will get the following unhandled error message:
If I now click on the provided Copy button, the whole message box is copied to the clipboard as text. If I paste it, the result looks like this:
C:\Visual DataFlex 17.0 Examples\Contact Management\Programs\Contacts.exe
Invalid message. MSG_REQUEST_ASSIGN
Error: 98
MSG_ONCLICK (4600) - OBUTTON1 (438) - at address 73367
MSG_COMMAND (648) - OBUTTON1 (438) - in native code
[start] - at address 77792
Once again, the full error message, this time including the full call stack leading up to the error, since it is an unhandled error, is available in simple text form, for emailing to support, copying into any search I want, etc.