View RSS Feed

Development Team Blog

Saving Error Messages in Text Form

Rate this Entry
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.
Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	CannotDeleteError.png 
Views:	869 
Size:	16.0 KB 
ID:	5294   Click image for larger version. 

Name:	UnhandledError.png 
Views:	829 
Size:	22.2 KB 
ID:	5295  

Updated 1-Dec-2013 at 12:40 PM by Vincent Oorsprong

Categories
Uncategorized

Comments

  1. Pieter van Dieren's Avatar
    Nice tip about the normal messageboxes. Didn't know that.

    As for the unhandled errors:
    It would be (very) nice if we could add our own buttons to the error dialog.
    We always explain to our users they can press the copy button, go to an e-mail and paste the text, but even that is for some of our users hard to grasp. ;-)
    So having the possibility to add a button 'E-mail error' or 'Send error to ...' would be a nice feature,

    Regards,

    Pieter
  2. Dennis Piccioni's Avatar
    Hi Pieter,

    the CallStackDump help shows you how to create a custom error handler.