Results 1 to 7 of 7

Thread: Error information [RESOLVED]

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Error information [RESOLVED]

    When an error occurs in my app, one of the things the error handler does is append some information to a log file such as date, time, error number and description.
    I'd like to add to that the name of the procedure where the error took place. Is it possible to retrieve this information somehow, I mean without having to use a variable to tag each and every subroutine in the app?
    Next I'd like to get the list of all the calling procedure's names and -this sounds even more difficult- the number of the line were the error was triggered. Any ideas?
    Last edited by krtxmrtz; Sep 18th, 2003 at 12:29 PM.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Posts
    187
    Here is some code I use in my app for error handling which writes the error to a log file:

    VB Code:
    1. On Error GoTo PROC_ERR
    2.  
    3. [COLOR=green]code goes here[/COLOR]
    4.  
    5. PROC_EXIT:
    6.         Exit Sub
    7.    
    8. PROC_ERR:
    9.      ErrorMsg Err.Number, Err.Description & ":" & CStr(VBA.Erl), "Save", TypeName(Me), _
    10.            Err.Source, SAVE_ERR
    11.         Resume PROC_EXIT
    ErrorMsg is a global functon. The parameters passed to it are:

    Err.Number - vb error ID number
    Err.Description - vb error description
    VBA.Erl - this is a undocumented function and will not show up in intellisense. This returns the line number where the error occurred, assuming ofcourse that you have line numbers in your code, otherwise it returns 0.
    "Save" - this is the procedure name
    TypeName(Me) - this is the module name
    Err.Source - Source of the error ie. the project name
    SAVE_ERR - a constant for the message box title

    The ErrorMsg function sorts all these parameters out in a string to be displayed to the user and written to the log file.

    Fortunately, I use CodeSmart and have this set up in a template which makes things easy.

    Cheers

    Jack
    Last edited by Jackalx25; Sep 17th, 2003 at 06:58 AM.

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573
    Originally posted by Jackalx25
    VBA.Erl - this is a undocumented function and will not show up in intellisense. This returns the line number where the error occurred, assuming ofcourse that you have line numbers in your code, otherwise it returns 0.
    ...
    Fortunately, I use CodeSmart and have this set up in a template which makes things easy.
    Hi Jack, (pun not intended)

    I being an amateur vb-er am not familiar with those terms. Just what is intellisense? How about CodeSmart? I'd really like to have line numbers in the code but how can you turn them on, if this can be done automatically?

    Thanks for the help.

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    I'm sure you use it all the time (Intellisense that is )

    MSDN

    The Text editor now features Automatic Statement Completion, also known as IntelliSense. IntelliSense puts the MFC, Win32, and ATL libraries virtually at your fingertips, displaying class members, function prototypes, identifier declarations, and code comments at the mouse or cursor location where you are editing your code. Simple keystrokes insert code elements directly into the source code file you're working in. IntelliSense also completes recognized words for you, saving you from having to type lengthy class or member names repetitively.
    There is no built in feature in vb that will generate the line numbers for you. To do that you need an addin for vb that can do this. CodeSmart is such an addin.

    you can offcourse type them in as you go along though...
    -= a peet post =-

  5. #5
    Addicted Member
    Join Date
    Aug 2002
    Posts
    187
    peet is spot on in what he says...

    Addins like Codesmart make doing the time consuming activities such as adding line numbers, formatting code etc etc. a snap.

    If you want something that is free you can get MxTools. You can get it at: www.mxtools.com

    I am sure it allows you put line numbers into your code but am not sure about it's flexibility in setting up error handling templates.

    About using VBA.Erl, if you type "VBA." vb will list a number of functions however you will not fine "Erl" among them. This is what I mean by not showing up in intellisense.

    Cheers

    Jack

  6. #6

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573
    The thing is I installed MZTools very recently but haven't played enough with it yet so I wasn't aware it could do that too.
    Thanks a lot guys!

Posting Permissions

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



Click Here to Expand Forum to Full Width