ErrorFunctionsΒΆ

error.spad line 1

ErrorFunctions implements error functions callable from the system interpreter. Typically, these functions would be called in user functions. The simple forms of the functions take one argument which is either a string (an error message) or a list of strings which all together make up a message. The list can contain formatting codes (see below). The more sophisticated versions takes two arguments where the first argument is the name of the function from which the error was invoked and the second argument is either a string or a list of strings, as above. When you use the one argument version in an interpreter function, the system will automatically insert the name of the function as the new first argument. Thus in the user interpreter function f x == if x < 0 then error "negative argument" else x the call to error will actually be of the form error("f","negative argument") because the interpreter will have created a new first argument. Formatting codes: error messages may contain the following formatting codes (they should either start or end a string or else have blanks around them): \%l start a new line \%b start printing in a bold font (where available) \%d stop printing in a bold font (where available) `` %ceon`` start centering message lines \%ceoff stop centering message lines \%rjon start displaying lines “ragged left” \%rjoff stop displaying lines “ragged left” \%i indent following lines 3 additional spaces \%u unindent following lines 3 additional spaces \%xN insert N blanks (eg, \%x10 inserts 10 blanks)

error: (String, List String) -> Exit
error(nam, lmsg) displays error messages lmsg preceded by a message containing the name nam of the function in which the error is contained.
error: (String, String) -> Exit
error(nam, msg) displays error message msg preceded by a message containing the name nam of the function in which the error is contained.
error: List String -> Exit
error(lmsg) displays error message lmsg and terminates.
error: String -> Exit
error(msg) displays error message msg and terminates.