NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting step error during Post-Step substep execution

There is custom step type, which defines Post-Step substep:
 

void

__declspec(dllexport) __stdcall PostStep(struct IDispatch* pSeqContextDisp)

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

PropertyObjectPtr spThisContext=pSeqContextDisp;

try

{

// ...

return PostStepEx(spThisContext);

}

catch(_com_error& xComErr)

{

// ...

}

}

void

PostStepEx(PropertyObjectPtr& spThisContext)

{

SequenceContextPtr spSeqContext=spThisContext;

StepPtr spStep=spSeqContext->GetStep();

PropertyObjectPtr spResultStep=spStep->AsPropertyObject();

bool fSomeCondition=false;

// Evaluate fSomeCondition

if(fSomeCondition)

{

spResultStep->SetValBoolean("Result.Error.Occurred", 0, VARIANT_TRUE);

spResultStep->SetValString ("Result.Error.Msg", 0, "Some error message");

spResultStep->SetValNumber ("Result.Error.Code", 0, -1);

return;

}

// Continue ...

}

When step of this custom step type is beeing executed and fSomeCondition evaluated to true, the error is displayed:

Details:

"Error executing substep 'Post'.
Some error message"

How to instruct TestStand to not to add prefix "Error executing substep 'Post'." ?

thanks.misha

0 Kudos
Message 1 of 19
(6,008 Views)
Hey Misha,

What kind of errors is TestStand catching?  Are they the _com_error& xComErr errors?  If you want to get around TestStand adding the prefix, you could handle the errors in your code and pass the error out without a throw statement.  I hope this helps.
Best Regards,
Software Engineer
Jett R
0 Kudos
Message 2 of 19
(5,989 Views)
Jett,
 
I think, there is no messing with catching - throwing errors. I handle errors in my code:

spResultStep->SetValBoolean("Result.Error.Occurred", 0, VARIANT_TRUE);

spResultStep->SetValString ("Result.Error.Msg", 0, "Some error message");

spResultStep->SetValNumber ("Result.Error.Code", 0, -1);

What should be done to achieve the goal?
 
thanks.misha
0 Kudos
Message 3 of 19
(5,969 Views)
Hi Misha,
 
Assuming you are using VisualStudio C++. Maybe your compiler options are bad. In my apps i am using multibyte character settings an this is working.
What happens if you are trying this spResultStep->SetValString ("Result.Error.Msg", 0, _bstr_t("Some error message"));

Why are you using the keyword __stdcall ? Is it working when you remove it?

Hope this helps

Juergen


 
 
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 4 of 19
(5,965 Views)

Jurgen,

The following two lines are equivalent:

spResultStep->SetValString ("Result.Error.Msg", 0, _bstr_t("Some error message"));

spResultStep->SetValString ("Result.Error.Msg", 0, "Some error message");

Calling convention (__stdcall) can not affect application logic.

The problem is not that this not works, but not works as expected. TestStand adds prefix to my message-this is what I'm trying to prevent.

thanks.misha

0 Kudos
Message 5 of 19
(5,961 Views)
Hi mishaw,
 
Sorry but i missunderstood your question. Forget my Stuff.
So what happens if you set  SetValBoolean("Result.Error.Occurred", 0, VARIANT_FALSE);

I know thats wrong but let's figure out whats happening.
 
Greetings
 
juergen
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 6 of 19
(5,953 Views)

Jurgen,

I tried your proposal. The result is the same.

Interestingly that's NI_MultipleNumericLimitTest's Post-Step set the error, and it appears without prefix.

I reviewed the NI code and not found principal difference with mine.

I don't understand where is my mistake. Can anyone help?

 

thanks.misha

0 Kudos
Message 7 of 19
(5,946 Views)
Hi Misha,
 
Do you use a CodeModule (NiMultipleNumericLimitTest) where you load your Dll Function?
 
 
Juergen
 
Stopp forget It !!  First time I overread "whitout "


Message Edited by j_dodek on 03-26-2008 02:46 PM
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 8 of 19
(5,935 Views)

Hi Misha,

I have written a smal StepType. It is the same.

It looks like, as you assumed, that there is a function around the postsubstep calls. And on Ni's it should be the same! If you are using a codemodule you will not enter with the module postsubstep with your dll.
I have found the Error string at ErrorStrings.ini   SUBSTEP_RTE_ELAB = "Error executing substep '%1'." But not found this define in a C* or h file in the hole TS folder

I think this is a task for the Ni-Guys here Smiley Wink

 

Greetings

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 9 of 19
(5,924 Views)
Hello Misha,

If you do not want the "Error executing substep 'Post'." string added to the beginning of your error message, you could use the following method. 

You can set only the Error message (Error.Msg) and Error code (Error.Code) and not the Error Occurred Flag (Error.Occurred) in the post step code module.  In the post-expression of that step, you can then detect whether the error code is non-zero and set the Error.Occurred flag to True if necessary.  See the screen shot below.

Let me know if you have any questions implementing this solution.




Message Edited by JettR on 03-27-2008 02:00 PM
Best Regards,
Software Engineer
Jett R
0 Kudos
Message 10 of 19
(5,899 Views)