05-30-2011 08:40 PM
05-31-2011 09:54 AM - edited 05-31-2011 09:54 AM
Are you trying to clear the error or set it?
You should be setting the error of the step, not the execution. You can even pass step.error.occurred, step.error.msg, and step.error.code as output parameters, though you can also do it programmatically similar to what you posted. Also, if you don't want the error to terminate the sequence, then you should set setting the "Ignore Errors" setting on the step.
Hope this helps,
-Doug
05-31-2011 11:41 AM
Thanks Doug.
Sorry how my last post was garbled -- I was blocking Lithium.com so the editor did not show in full.
Either way, the sample code I included
Public Shared Function ClearErrorObject(ByVal sequenceContext As NationalInstruments.TestStand.Interop.API.SequenceContext) As Boolean Dim errorObject As PropertyObject = sequenceContext.Execution.ErrorObject() errorObject.SetValBoolean("Occurred", 0, False) errorObject.SetValString("Msg", 0, "") errorObject.SetValNumber("Code", 0, -1) Dim code As Integer = CInt(errorObject.GetValNumber("Code", 0)) Return True End Function
was inteded to test changing the error object. Once I have that tested, I would pass an execption to a call to set the step error.
However, I am at a loss attempting to grab reference to the step error object.
Could you share a code snippett with me showing how to get reference to the step error object?
Thanks.
David
05-31-2011 12:09 PM
Doug,
Got it. This works.
Public Shared Function SetStepResultError(ByVal sequenceContext As NationalInstruments.TestStand.Interop.API.SequenceContext) As Boolean Dim errorObject As PropertyObject = sequenceContext.Execution.ErrorObject() Dim stepResult As NationalInstruments.TestStand.Interop.API.Step = sequenceContext.Step() stepResult.AsPropertyObject.SetValBoolean("Result.Error.Occurred", 0, True) stepResult.AsPropertyObject.SetValString("Result.Error.Msg", 0, "Error occurred") stepResult.AsPropertyObject.SetValNumber("Result.Error.Code", 0, -1) Dim code As Integer = CInt(stepResult.AsPropertyObject.GetValNumber("Result.Error.Code", 0)) Return True End Function
06-01-2011 09:55 AM
Looks good. Glad I could help. You could also pass those properties as byref parameters if you prefer. For example (not sure this is correct syntax, my VB knowledge is a bit rusty, but hopefully it's close enough):
Public Shared Function SetStepResultError(ByRef errorOccurred As Boolean, ByRef errorMessage As String, ByRef errorCode as Integer)
errorOccurred = True
errorMessage = "my error message"
errorCode = -1
End Function
Hope this helps,
-Doug