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.
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.
neterror:
  Network error (refused connection, timeout, unreachable net, etc.).
rangecheck:
  Out of bounds string or array access.
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.
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: 2.7 Threads Up: 2. Onyx Language Reference Previous: 2.5 Interpreter recursion Contents Index