Try
From Mesham
Jump to navigationJump to search
Contents
Syntax
try
{
try body
} catch (error string) {
error handing code
}
Semantics
Will execute the code in the try body and handle any errors. This is very important in parallel computing as it allows the programmer to easily deal with any communication errors that may occur.
Error Strings
There are a number of error strings build into Mesham, additional ones can be specified by the programmer.
- Array Bounds - Accessing an array outside its bounds
- Divide by zero - Divide by zero error
- Memory Out - Memory allocation failure
- root Illegal - root process in communication
- rank Illegal - rank in communication
- buffer Illegal - buffer in communication
- count - Count wrong in communication
- type - Communication type error
- comm - Communication communicator error
- truncate - Truncation error in communication
- Group - Illegal group in communication
- op - Illegal operation for communication
- arg - Arguments used for communication incorrect
Example
try { print[a#12]; } catch ("Array Bounds") { print["No Such Index\n"]; };
In this example the programmer is trying to access element 12 of array a. If this does not exist, then instead of that element being displayed an error message is put on the screen.