AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
catch grammar
 
A statement, used in conjunction with the try statement, that provides control over error handling. When an error occurs in the block associated with a try statement, control passes to the associated catch block and information about the error is stored in a dictionary that can be referenced by name in the catch block. A catch block that returns a zero value (i.e., FALSE) is asking the interpreter to continue with its normal error handling, which includes writing an error message on standard error. In all other cases (i.e., a non-zero or missing return value) error handling is short-circuited, the error message is suppressed, and execution continues at the statement that immediately follows the try/catch block. Its usage description can be summarized as follows:
Statement:
	try Compound catch ( name ) Compound
 
 Example:   The following script demonstrates the effect of the return value in a catch statement.
import yoix.stdio.*;

printf("Test #1:\n");
try {
    vbl;  // undefined
}
catch(error) {
    printf("Message #1: %s\n", error.message);
    return(FALSE);      // allows system error message
}
printf("Test #2:\n");
try {
    vbl;  // still undefined
}
catch(error) {
    printf("Message #2: %s\n", error.message);
    // no return statement suppress system error message
}
printf("Test #3:\n");
try {
    vbl;  // still undefined
}
catch(error) {
    printf("Message #3: %s\n", error.message);
    return(TRUE); // suppress system error message
}
printf("Testing completed.\n");
The results on standard output would look something like:
Test #1:
Message #1: Error: undefined; Name: vbl; Line: 5; Source: /tmp/xxx
Error: undefined; Name: vbl; Line: 5; Source: /tmp/xxx
Test #2:
Message #2: Error: undefined; Name: vbl; Line: 13; Source: /tmp/xxx
Test #3:
Message #3: Error: undefined; Name: vbl; Line: 21; Source: /tmp/xxx
Testing completed.
 
 See Also:   reference, try

 

Yoix is a registered trademark of AT&T Inc.