Sfairadora

  • Reference Guide

error

error(description)
error(description, base)
error(code, base)
error(code, description, base)
The function creates a value of the type Error. Such a value serves to represent information about a run-time error in the Enki language. It is not necessary to return explicitly an error value with the return statement. It is sufficient to present such a value at any place in the computation flow – it will be propagated up by the standard mechanism until it is handled (see the chapter Error Handling) or returned as the result of the whole function. All the error values created this way will be of the ERROR_USER category.
Example 1:
if(x > 100)
error("number too big");
Example 2:
try
(
...
str = read_line(f);
...
)
else
(
error("unable to read from the file X.Y ", last_error)
)
Here, an error value describing the problem at the higher level is appended to the error value resulting from reading from the file. The lower-level error (last_error) is nested to the error value created as its base error. This provides the user with more detailed and appropriate information on the error.

Parameters

description
The description of the error. It should be entered with the first letter lower-case and without the dot at the end. Sfairadora converts the first letter to upper-case and appends a dot as needed, because when the list of nested errors is assembled, only the first error description should be capitalized an the dot should be placed only at the end of the list.
code
The error code assigned by the user for easier identification of the error in the program. The value is of the type Dword. If no code is specified, the value 0xFFFFFFFF is used (the maximum value of the Dword type).
base
The error (a value of the type Error) that is the cause of the error being constructed, and thus should be nested to it as its cause.

See Also