Exception and error handling, Error mechanisms for the c++ interface – Teledyne LeCroy Automation API for IBTrainer Software Ver.2.0 User Manual

Page 15

Advertising
background image

Packet Handling Concept

Programming the IBTrainer

CATC IBTrainer InfiniBand Exerciser API Reference

1-5

Exception and Error Handling

This section shows the error mechanisms implemented by the C++ and
the TCL interfaces.

Error Mechanisms for the C++ Interface

The following code block shows an example of how to use the exception
handling with the API.

try

{

IGCGenerator myGenerator;

myGenerator.Connect(0);

myGenerator.Foo();

}

catch (IGCError err)

{

// Error occurred in try block

// Do error handling here, e.g. print error message:

cerr << "Error occurred: " << err;

}

To throw an error, use a line similar to the one below:

throw(IGCError(IGCError::IGE_FATAL, "Cannot close device"));

See also the descriptions in

“Methods of the IGCPacketHandler Class”

on page 2-103

and

“EErrtype” on page 3-1

.

Advertising