next up previous contents index
Next: 2.7 Threads Up: 2. Onyx Language Reference Previous: 2.5 Interpreter recursion   Contents   Index

2.6 Error handling

The error handling mechanisms in Onyx are simple but flexible. When an error occurs, throw is called. An error can have any name, but only the following error names are generated internally by Onyx:

argcheck:
Incorrect argument value.
cstackunderflow:
Not enough objects on cstack.
estackoverflow:
Maximum interpreter recursion was exceeded.
invalidaccess:
Permission error.
invalidcontinue:
The continue operator was called outside of any loop. This error is generated as a result of catching a continue, so the execution state for where the error really happened is gone.
invalidexit:
The exit operator was called outside of any loop. This error is generated as a result of catching an exit, so the execution state for where the error really happened is gone.
invalidfileaccess:
Insufficient file permissions.
ioerror:
I/O error (read(), write(), etc.).
limitcheck:
Value outside of legal range.
neterror:
Network error (refused connection, timeout, unreachable net, etc.).
rangecheck:
Out of bounds string or array access, or out of bounds value.
regexerror:
Regular expression syntax error.
stackunderflow:
Not enough objects on stack.
syntaxerror:
Scanner syntax error.
typecheck:
Incorrect argument type.
undefined:
Name not defined in any of the dictionaries on dstack, or in the case of class method dispatch, name not defined in the class hierarchy.
undefinedfilename:
Bad filename.
undefinedresult:
Attempt to divide by 0.
unmatchedfino:
No fino on ostack.
unmatchedmark:
No mark on ostack.
unregistered:
Non-enumerated error.

The Onyx scanner handles syntax errors specially, in that it pushes an executable string onto the operand stack that represents the code that caused the syntax error and records the line and column numbers in currenterror before invoking throw .

The Onyx scanner also handles immediate name evaluation errors specially, in that it pushes the name that could not be evaluated onto ostack before invoking throw .

In addition to the throw operator, there are several other operators that exist specifically for the purpose of error handling. The start operator silently catches any uncaught stop , exit , continue , escape , or quit calls. The start operator is the first operator called by the Onyx interpreter during startup, and it can also be used by applications to limit execution stack unwinding. The stopped operator is useful for catching stop calls, since it reports whether a stop call was caught, allowing conditional error recovery.


next up previous contents index
Next: 2.7 Threads Up: 2. Onyx Language Reference Previous: 2.5 Interpreter recursion   Contents   Index
Jason Evans 2005-03-16