| catch |
|
grammar |
| |
A statement, used in conjunction with the
try
statement, to provide control over error handling.
When an error occurs within the context block associated with the
try
statement, control passes to the
catch
block with the variable indicated by
name
containing information about the error.
Moreover, if the
catch
block contains a return statement with a non-zero (i.e.,
true)
return value, then no error message is sent to standard error.
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); // will allow system error message
}
printf("Test #2:\n");
try {
vbl; // still undefined
}
catch(error) {
printf("Message #2: %s\n", error.message);
// no return statement also allows system 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: catch.yx
Error: undefined; Name: vbl; Line: 5; Source: catch.yx
Test #2:
Message #2: Error: undefined; Name: vbl; Line: 13; Source: catch.yx
Error: undefined; Name: vbl; Line: 13; Source: catch.yx
Test #3:
Message #3: Error: undefined; Name: vbl; Line: 21; Source: catch.yx
Testing completed.
| | |
| See Also: |
reference,
try
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|