Programmatically getting the line number of an error in VBScript

Basically, I want my script to log any errors it encounters and log the line number of the error.  I'd like to do this just using VBScript.  Is this possible?
Who is Participating?
Hi, there is no line number property, but you can try using the Source property to determine which object raised the error.

Otherwise you'd have to put in your own line number indicators.  For example, in judgeking's code above, you'd use something like
LogError "Error " & Err.Number & " was raised on line 6."

but that, of course, requires that you manually update the string each time you change the code.


judgekingAuthor Commented:
Thanks, but I'm already doing this type of error checking, what I want is something like this:
'main VBScript code here
'... some code
'... some more code
If Err.Number <> 0 Then
   LogError Err.Number, Err.Description, Err.LineNumber
End If

Open in new window

Oh, you *are* judgeking....ignore that bit... :-)
judgekingAuthor Commented:
OK, I didn't think it was possible to get the line number, but I just wanted a second opinion.  Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.