[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5714
  • Last Modified:

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?
0
judgeking
Asked:
judgeking
  • 2
  • 2
1 Solution
 
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

0
 
RobSampsonCommented:
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.

Regards,

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now