APIs, concepts, guides, and more

◆ ThrowExceptions()

void ThrowExceptions ( bool state)
inherited
Description:
ThrowExceptions configures a class to throw execptions.
Parameters
stateIf state is true, any methods in this class will throw exceptions if any errors occur. If state is false, the methods will log software errors for reading at a later time
Sample Code:
Monitoring: Error Logging
// turn exceptions off (errors will be logged as RsiError objects)
controller.ThrowExceptions(false);
axis.ThrowExceptions(false);
// cause an errors
controller.RecorderStart(); // recorder count is zero
axis.MoveVelocity(0.0, 0.0); // zero acceleration
// print error count
var controllerErrorCount = controller.ErrorLogCountGet();
var axisErrorCount = axis.ErrorLogCountGet();
Console.WriteLine($"Controller error count: {controllerErrorCount} (expected: 1)");
Console.WriteLine($"Axis error count: {axisErrorCount} (expected: 1)");
// print controller errors
while(controller.ErrorLogCountGet() > 0)
{
// ErrorLogGet retrieves and removes the next error from the log
RsiError error = controller.ErrorLogGet();
Console.WriteLine($" Controller Error: {error.Message}");
}
// print axis errors
while( axis.ErrorLogCountGet() > 0)
{
RsiError error = axis.ErrorLogGet();
Console.WriteLine($" Axis Error: {error.Message}");
}
// print error count after reading logs
Console.WriteLine($"Controller error count: {controller.ErrorLogCountGet()} (expected: 0)");
Console.WriteLine($"Axis error count: {axis.ErrorLogCountGet()} (expected: 0)");
Note

All classes will throw exceptions by default.
See also
ErrorLogGet
Examples
error-logs.cs.