edu.princeton.toy.lang
Interface TExceptionHandler

All Known Implementing Classes:
TDefaultExceptionHandler

public interface TExceptionHandler

TExceptionHandler essentially maintains a list of what exceptions to ignore and what exceptions to propagate throughout the virtual machine (halting the TVM).


Field Summary
static TExceptionHandler PROMISCUOUS_EXCEPTION_HANDLER
          An implementation of TExceptionHandler which ignores all exceptions.
static TExceptionHandler PRUDISH_EXCEPTION_HANDLER
          An implementation of TExceptionHandler which throws all exceptions.
 
Method Summary
 boolean getWillThrow(int index)
          Gets wheter or not the handler should throw a raised exception of the specified type.
 boolean getWillThrow(TExceptionType type)
          Gets wheter or not the handler should throw a raised exception of the specified type.
 void raise(TExceptionType type)
          Throws a TException with the specified type iff the specified exception was not set to be ignored.
 

Field Detail

PROMISCUOUS_EXCEPTION_HANDLER

static final TExceptionHandler PROMISCUOUS_EXCEPTION_HANDLER
An implementation of TExceptionHandler which ignores all exceptions.


PRUDISH_EXCEPTION_HANDLER

static final TExceptionHandler PRUDISH_EXCEPTION_HANDLER
An implementation of TExceptionHandler which throws all exceptions.

Method Detail

raise

void raise(TExceptionType type)
           throws TException
Throws a TException with the specified type iff the specified exception was not set to be ignored. The Virtual Machine should raise all exceptional conditions and let the handler decide wheter or not that exception should be propagated through the rest of the machine.

Parameters:
type - The type of exceptional condition that was raised in the Virtual Machine.
Throws:
TException

getWillThrow

boolean getWillThrow(int index)
Gets wheter or not the handler should throw a raised exception of the specified type.

Parameters:
index - The index of type (in the TExceptionType.TYPES array) in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
True iff the handler will throw exceptions of this type.
See Also:
TExceptionType.TYPES

getWillThrow

boolean getWillThrow(TExceptionType type)
Gets wheter or not the handler should throw a raised exception of the specified type.

Parameters:
index - The type in question. A null value will result in a NullPointerException.
Returns:
True iff the handler will throw exceptions of this type.
See Also:
TExceptionType.TYPES