Alpha Video Training
Results 1 to 3 of 3

Thread: Generating error messages: conventions?

  1. #1
    Member abackstrom's Avatar
    Real Name
    Adam Backstrom
    Join Date
    Apr 2005

    Default Generating error messages: conventions?

    I'm writing some fairly complex functions, and running lots of sanity checks along the way. Right now, I have a few calls to error_generate(), but my error handling is far from perfect. I was wondering how others deal with this aspect of Xbasic programming.

    I think my two main options are 1) error_generate() and on error goto, and 2) ui_msg_box() and special function return values which signal some sort of failure. At this point, I can't see the forest for the trees. I'm leaning towards error_generate(), but if anyone has sugguestions I'd be glad to hear them.
    Adam Backstrom <>

  2. #2
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Boston, Massachusetts, USA


    It depends upon the purpose of the function and how it is used.

    My general best method returns an error value so that the calling routine can process the error, and potentially pass it up the chain of calls

    Sometimes, you want to ask the user as to what to do, with a UI call, so that he can make an intelligent response as to what to do, but then this can be repeated alot if many errors crop up, annoying the user. At this point, you can often ask the user what he'd like to do automatically in the future for this kind of error, thus allowing the multiple calls to complete without constant prompting.

    Also, sometimes you want to log the error to a file or table or sometimes just a global variable.

    Something I often do is add an optional parameter at the end of the function arguments (typically called Flags) that allows me to specify how I want to handle errors for this call, as well as specify other things to the function. This is often just a character type argument with a default value of "", which I interpret as a default set of flags - typically standard return with error values.

    I never have used error_generate(), except to force an error handler to be invoked. I believe this is typically bad programming practice for a function. The only good reason to use this is to force an error branch when you can't return it as the function's value, but I have never found a case where I can't come up with a return method.

    Ira J. Perlow
    Computer Systems Design

    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture

  3. #3
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Atlanta, GA


    A couple of things to remember ..

    In a script or function, On error goto label will remain in force unless you insert an On error goto 0 to restore default A5 error trapping.

    In addition you have error_text_get() and a bunch of other error functions to show unexpected errors. These are listed in the online help.


Similar Threads

  1. Error Messages 1
    By julian lewis in forum Alpha Five Version 6
    Replies: 5
    Last Post: 12-30-2004, 04:49 PM
  2. Error messages
    By dchiass in forum Alpha Five Version 5
    Replies: 7
    Last Post: 04-08-2004, 07:27 AM
  3. Error messages
    By Gary Fox in forum Alpha Five Version 1
    Replies: 1
    Last Post: 11-14-2003, 05:46 PM
  4. Error Messages
    By Joe T. Buchanan in forum Alpha Five Version 5
    Replies: 6
    Last Post: 08-29-2003, 09:29 AM
  5. error messages
    By mel in forum Alpha Five Version 5
    Replies: 1
    Last Post: 11-09-2002, 10:50 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts