Home
 Introduction
 Using Holon
 Holon Tools
 Contact


 HolonJ

 HolonJForth
    Classes
    Methods
    Parameter
    Variables
    Forth
    FlowControl
    Compiler
    Libraries
    Constructors
    Exceptions 

 UsingHolonJ

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. 

 

 

© 1999-2005 Wolf Wejgaard