NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy Step.Result.Error.Code to Local Variable

Solved!
Go to solution

How I can copy Step.Result.Error.Code for a particulat step to a Local variable.

 

I want to print the value of Step.Result.Error.Code  in my test report.

 

Please help. thanks in advance.

 

Regards,

Sagar Joshi

0 Kudos
Message 1 of 6
(1,497 Views)

Hi Sagar,

 

You could copy the error code to the ReportText, using the following post-expression:

 

Step.Result.ReportText = (Step.Result.Error.Occurred == True ? "Error Code: "+ Str(Step.Result.Error.Code) : "")

 

 

Regards,

 

Charlie

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 2 of 6
(1,494 Views)

Thanks  CharlieRodway, But I guess the post expration will not execute if any error occure while executing the step. Right?

 

I earlier used following expration in post expration. Nut I saw that the Local variable is not updating on Step failure.

 

Local.StepErrorCode = Step.Result.Erroe.Code 

0 Kudos
Message 3 of 6
(1,491 Views)

Hello CharlieRodway,

 

I tried your solution but the Post Expration is not executed when the step if failed. 

 

When I am monitoring the Step.Result.Error it has updated the error code. Msg and Occured to True, But the Result.ReportText is not updated. 

 

It means that the Post expration is not executed when the Step is failed.

0 Kudos
Message 4 of 6
(1,484 Views)
Solution
Accepted by topic author joshisagarr

Yes, of course!

 

This is best handled by the SequenceFilePostStepRuntimeError Callback:

 

1). Add StepResultCode (Number) to FileGlobals

2). Add SequenceFilePostStepRuntimeError Callback to your sequence file

3). Add the following Statement step to the SequenceFilePostStepRuntimeError Callback:

 

FileGlobals.StepErrorCode = Parameters.Step.Result.Error.Code

 

Here's a snapshot of the sequence:

 

StepErrorCode.PNG

 

I hope this help,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 5 of 6
(1,483 Views)

Thanks a lot Charlie Rodway

0 Kudos
Message 6 of 6
(1,477 Views)