Skip to main content

Error Help

I'm adding errorhandlers to a series of pre-existing scripts.  These scripts are for analysts with a wide variety of technical ability to use so I'm trying to keep them simple.  One thing I've been unable to find is a list of the properties IDEA makes available for an error object (.number, .description, .WhatElse?).  The two scenarios where I need more information than I have are as follows:
1) An extraction or join fails due to a missing field.  I can return the error message "The specified field was not contained in this database" but I need to identify which field is being referenced.  Can I do that with an errorhandler?
2) The default error IDEA messages identify which line of the script caused an error.  How do I reference the error line in an errorhandler?
Any help with these two needs would be GREATLY appreciated!

Brian Element Sat, 01/15/2022 - 06:08

For part one here is some code from an older IDEAScript training manual.  There is just the error number and description that I know of for both IDEA errors and window errors:


Sub Main
' On error go to label ErrHandler
On Error GoTo ErrHandler
Dim db as object
' Open a non-existent database to generate an error
Set db = Client.OpenDatabase("C:\IDEA\noSuchFile.IMD")
Exit Sub
ErrHandler:
If Client.ErrorCode > 0 Then
Msg = "Error: " & Client.ErrorString
Else
Msg = "Error # " & str(Err.Number) & Chr$(13) & Err.Description & Chr$(13)
End If
Response = MsgBox(Msg, MB_OK, "IDEAScript Error")
End Sub

For the second question I have seen some script that will insert a variable to check the line number, so you would have a global variable such as:

dim line_number as integer

And then in your code every so oftern you would update the line_number with the location in the script such as:

line_numer = 100

Then you would reference it in the on error section of your code.