Is there an equivalent to Visual Basic‘s On Error Resume Next for C++ where by if an error occurs code continues to execute without prompting user?
Ideally, would like to catch any exceptions and log them to log.txt file and examined later instead of having exceptions abruptly exiting code.
Visual Basic:
For i = 1 to 100
On Error Resume Next
ReturnedOpcVal[i] = OPC.ReadTag(“Server.Path.Tag” & "TagName_" & Cstr(i))
Next i
C++, I’m thinking this:
Try {
// Try looping through code here
For (i = 1; i <= 100; i++)
{
// Read OPC tags code here
}
}
Catch(…)
{
// log error to file code
}
There's nothing like that. You'd have to write your code to catch and swallow the exception. Something like this:
for(int i=1; i<=100; i++)
{
try
{
// Read OPC tags code here
}
catch(...)
{
// Log something
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With