[Next] [Prev] [Right] [____] [Up] [Index] [Root]
error statement

error statement

The syntax of the error-statement is:

error EXPRESSION, ..., EXPRESSION;

It is used inside the statement body of a function or procedure expression. It cannot be used within a func< > constructor.

If Magma encounters an error-statement when executing a function call or procedure call, then it prints the values of EXPRESSIONs as output. After that, Magma breaks out of the call.

In the case of a function call where an error-statement is executed, no values are returned from the function. (This is also true for calls to intrinsic functions that result in errors.)

Example

> Stars := procedure(n)
procedure> if n notin [0..80] then
procedure|if> error "Runtime error in 'Stars': Argument 1 (", n,                 
procedure|if|error> ") not in range [0..80]";
procedure|if> else print "*"^n; 
procedure|if> end if;
procedure> end procedure;
> Stars(15);           
***************
> Stars(81);
Runtime error in 'Stars': Argument 1 ( 81 ) not in range [0..80]
[Next] [Prev] [Right] [____] [Up] [Index] [Root]