Error Handing

Next: , Previous: Loops, Index: Index

Dynamic error handing is a vital part of many languages - it is considered especially important when dealing with a parallel language as communication is used (with all the errors it might present.)

try
{
code
} catch ("[error]") {
error handing code
};

If a dynamic (runtime) error is detected, then the code in the try block is aborted and execution jumps directly to the error handing code. The [error] string in the catch part defines which error will be caught. The empty string "" signifies catch any error. Try blocks can be nested.

If a try block is not used, and a dynamic error occurs then after a diagnostic message program execution will cease. At the moment there is quite limited error checking, it is hoped to extend this as the language develops.

Error Strings

String Applies to
"" All errors
"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

Examples

try
{
var p:array[Int,200] :: allocated[multiple[]];
(p#pid[]):=28;
} catch "Memory Out" {
print["Error!!"];
}

In the example during runtime, if the allocation of memory for array p fails, then the catch code (displaying a message) will be executed. However, if the pid[] function (get the processes's current ID) returns a value which is out of the array bounds, then this error will cause a default message to be displayed followed by termination of the code. Two comments can be made about this code, firstly note the lack of array row or column wise allocation information (in this case, the default row major is used.) Secondly, array bounds checking is also carried out statically (at compile time) if possible, so if a value were used, such as p#6 or a variable whos value is known then any errors will be detected before this point. If the compiler has been able to check statically and is satisfied that an error will not occur then, for efficiency, no dynamic error checking is issued.

Last Modified: August 2008