Error mechanism for the tcl interface – Teledyne LeCroy Automation API for IBTrainer Software Ver.2.0 User Manual

Page 16

Advertising
background image

Programming the IBTrainer

Packet Handling Concept

1-6

CATC IBTrainer InfiniBand Exerciser API Reference

Error Mechanism for the TCL Interface

The following example script shows how an IB

Trainer

gets connected

using the TCL script language and shows the error mechanism in case
the connect was not successful.

if { [catch {

set portnum 0

set gen [new_IGCGenerator]

IGCGenerator_Connect $gen $portnum

} result]} {

# error while establishing connection

puts stderr "ERROR: Cannot connect to generator at port $portnum:

$result"

} else {

puts "Connected on port $portnum"

}

In order to throw an error, use the following script command.

error "Fatal error: Cannot <do whatever the task was>"

The error command terminates the script unless the error is caught by
a catch command. Errors from the class igapi are automatically caught,
that is, the error message is printed to stderr (interactive mode) and the
corresponding tcl function returns with TCL_ERROR.

Advertising