DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

what sort of error handling is ther in Diadem SCRIPT?

I know and am using:

On Error Resume Next
On Error GoTo 0

However, I want to be able to go to the bottom of my script and finish some items and end the script as if everything executed properly. 

I was hoping to do something along the lines of a try...catch block, but appearantly there is not anything like that inside VB.

Thanks!
0 Kudos
Message 1 of 4
(4,100 Views)

Hi

There is an Err object to get or clear the last error. Search for "Err Object" in the help:

On Error Resume Next
Err.Raise 6   ' Raise an overflow error.
MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)
Err.Clear      ' Clear the error.

On other solution are some special Events: Try this small script. There is an spelling error in the second line but the Event_terminate event is executed properly.

Set SystemEvents = New SystemEventClass
Msgbx "hallo"

Class SystemEventClass
  Private Sub Class_Initialize   ' Initialize Event
    Call MsgBoxDisp("Initialize")
  End Sub
  Private Sub Class_Terminate   ' Terminate Event
     Call MsgBoxDisp("Terminate")
  End Sub
End Class

Hope this helps

Winfried

0 Kudos
Message 2 of 4
(4,089 Views)

Hi, this is quite old, from 2006. Is there some similar way to handle errors as there is no support for handler in Diadem for "On Error goto handler"

and used in script:

 

....
exit sub
 handler: here for example closing files

 

 

the event script doesnt work for me, the classes methods are executed, but the errror triggers after the terminate method, not opposite way, so its not usefull imho

0 Kudos
Message 3 of 4
(2,401 Views)

Hi Lukas,

 

This is my preferred approach-- wrap only the "touchy action" inside the On Error structure, plus variable assignments to capture the reasons for the error.  The Err object loses all its information as soon as On Error Goto 0 is executed, so trapping that info in variables is required.  I find it VASTLY preferable to apply branching logic outside the On Error structure, so that any errors in the branching code can be found. 

Dim ErrNum, ErrMsg, ErrSrc

On Error Resume Next
TouchyAction = 9/0
ErrNum = Err.Number
ErrMsg = Err.Description
Errsrc=Err.Source
On Error Goto 0

IF ErrNum <> 0 THEN Call YourTerminateSub(ErrNum, ErrMsg, ErrSrc)

' else proceed with the main script
LogFileWrite "--------------------"
LogFileWrite "Script finished without error!"
LogFileWrite "TouchyAction = " & TouchyAction


Sub YourTerminateSub(ErrNum, ErrMsg, ErrSrc)
  LogFileWrite "--------------------"
  LogFileWrite "ErrNum = " & ErrNum
  LogFileWrite "ErrMsg = " & ErrMsg
  LogFileWrite "Errsrc=" & ErrSrc
  LogFileWrite "Terminating now..."
  Call AutoQuit()
End Sub ' YourTerminateSub()

 

Brad Turpin

Senior Product Support Engineer

National Instruments

0 Kudos
Message 4 of 4
(2,390 Views)