Next: 1.6 Threads Up: 1. Onyx Language Reference Previous: 1.4 Interpreter recursion Contents Index

# 1.5 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:

dstackunderflow:
  An attempt was made to remove one of the initial dictionaries from dstack.
estackoverflow:
  Maximum interpreter recursion was exceeded.
invalidaccess:
  Permission error.
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.
rangecheck:
  Out of bounds string or array access.
stackunderflow:
  Not enough objects on ostack.
syntaxerror:
  Scanner syntax error.
typecheck:
  Incorrect argument type.
undefined:
  Name not defined in any of the dictionaries on dstack.
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 .

Next: 1.6 Threads Up: 1. Onyx Language Reference Previous: 1.4 Interpreter recursion Contents Index