numeric: R_error_code, R_error_index, R_warning_code, R_warning_index
composite: R_error_script, R_warning_script
The error and warning registers are modified by three built-in Yazoo functions. Compile-time errors are returned by compile(). Certain pathologies in bytecode are returned by transform(). Runtime errors and warnings may be caught using trap(). All three of these functions use R_error_code as the return variable.
Every error is assigned a numeric code which is stored in R_error_code. The names and descriptions of the error codes are described later in this document. An error code of zero always means no error.
The value of R_error_index defines the location of an error. compile()-generated errors return the character position at which the error was flagged in the source code, beginning at `1`. On the other hand, errors generated by transform() and trap() give the position of the error as an index, again beginning at `1', of an array of long-integer words containing the bytecode. Thus an error index of `14' represents an error flag either at the 14th character of uncompiled source code (in the case of compile()), or else at the 14th word of bytecode (bytes 53-56 if the computer uses 4-byte long words).
When trap() catches a runtime error, the offending bytecode is transformed into the type/code of the composite error register R_error_script. This allows the user to back out the problem by using variable_code(R_error_script) to return this bytecode as a string. (This strategy is used by the disassemble() routine in start.zoo to flag bytecode errors directly when the text of the original script is not available.) The two-step process of trapping the error and then copying the script to a string may seem inconvenient; it is done this way because it is internally faster to do this than to copy every error-script into a string, when in many cases only a minority of errors are actually examined by the user.
A warning differs from an error in that warnings do not stop execution. Warnings are treated exactly analogously to errors, and R_warning_code, R_warning_index and R_warning_script work in almost exactly the same way as their R_error_ counterparts. The main difference is that warnings can only be detected using trap(), as neither compile() nor transform() will alter the warning registers. (transform() actually can generate warnings, but in order to catch them transform() must be enclosed within a trap() statement). R_warning_code is not used as the return variable for any Yazoo function.
Last update: July 28, 2013