Error Levels, Run-Time Errors
Updated: Jan 6, 2012

Compiler Error Levels
~~~~~~~~~~~~~~~~~~~~~
The ExitProcess code of hot.exe returns 5 error levels:
  
  0 No Error
  1 Warning(s)
  2 ERROR parsing source code
  3 ERROR producing object module
  4 ERROR linking object modules

Please see Objects > Application for further description.


Application Run-Time Errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 Library not found    LIB file in DECLARE statement not found.
  2 Function not found   Function in DECLARE not found in LIB file.  
  3 Insufficient memory  Application request for RAM caused error.
  4 Array index error    Array subscript(s) out of bounds.
  5 Resource not found   Extraction statement did not find resource.
  6 Variant type error   Variant has invalid or mismatched type. 

Run-time errors result in an error message window followed by program exit
with exit code (error level) 1 to 6.  On Linux, error messages are printed
to the Terminal program.

However, program exit on fatal run-time error may be avoided with HotBasic's
exception handling using internal variable hbTrap. The default for hbTrap is
zero, in which cause the program terminates after reporting the above run-
time errors. If code assigns an exception handling entry address to hbTrap,
instead of program exit, that exception handling code is run. Example:

hbTrap = codeptr(Fatal_Error)

Upon entry to hbTrap code, internal variable hbError contains the run-time
error code 0 to 6 above and RETFUNC points to the error text above.

err_trap.bas in \tutorial\HotTrial provides further detail on hbTrap usage.

Applications may use FPU.Error or App.OnFPUerror to trap run-time FPU errors
(Objects > FPU).  .OnExit (Objects > APPLICATION) and FORM .OnClose may also
be used to flag various fatal errors.

Robust applications will check arguments and results *before* a serious error
condition occurs.  For example, one can test first if a divisor is zero or if
a file exists before FILE .Open, etc.


Copyright 2003-2012 James J Keene PhD
Original Publication: Oct 9, 2003
