HolonJ Forth
Using HolonJ
Clock
Tic Tac Toe

Classes
Methods
Parameter
Variables
Forth
Flow Control
Compiler
Libraries
Constructors
Exception

Exceptions

HolonJ implements the Java exception handling mechanism with Try, Catch, Throw, and CatchAll. Syntax:   

try     <try-action>
catch ExceptionClass
         <catch-action> ;

Example:  

try     <numberconversion>
catch NumberFormatException
         <exceptionhandling> ;

The event object is delivered on TOS. The method getMessage of java.lang.Throwable retrieves an exception message from the object.

CatchAll starts an exception handler, which catches all exceptions. The exception object is on TOS, when the handler is called. The name of the exception can be determined with the method toString.

try         <try-action>
catchall <exception-handler>  ;            \ no exception class needed here

A nice exception handler during debugging is "toString type". It tells you all about the exceptions that happen.

Throw creates a new exception object and calls athrow. 

throw ArithmeticException ()

" error message" throw ArithmeticException ( string -- )

HolonJ is restricted to one Catch or CatchAll handler in the same word (method).

The finally clause is not implemented.