Class Try

Summary

The singleton Try class implements the basic try structure.

Superclasses:
Object

Package:
exception
File:
exception.icn
Methods:
call, catch, getException, isException, showException, throw

Methods inherited from Object:
Type, className, clone, equals, fieldNames, genMethods, getField, get_class, get_class_name, get_id, hasField, hasMethod, hash_code, instanceOf, invoke, is_instance, setField, to_string

Fields:
exceptions, lastException, sources

Source code.

Details
Constructor

Try()

Get access to the singleton Try object. Once you have access to it you can call call{} and catch() to perform exception handling.

Methods:

call(L)

Returns:
an exception or the result of evaluating the try-clause
Fails:
if the try-clause fails

A PDCO (makes a co-expression out of its argument) that evaluates the argument in an environment supporting Exceptions.

Array of co-expressions when called as PDCO.


catch(exceptionName)

Returns:
the matched exception
Fails:
if no match

Catch an exception. Succeeds if the last thrown Exception is an instance of the named Exception. A null argument defaults to "exception::Exception".

name of exception to catch


getException()

Returns:
last thrown exception. Only valid when used after a throw(). Returns &null if no exception throws


isException(x, eName)

Parameters:
x
possible Exception
eName
subclass of Exception that x must match
Returns:
x if x is an Exception
Fails:
if x is not an Exception


showException(outFile)

Parameter:
outFile
-- output stream (defaults to &errout)

Display the exception thrown from this try clause.


throw(exception)

Throw an exception. Not called directly, but called indirectly by Exception.throw().

Exception to throw.


Fields:
exceptions

lastException

sources


This page produced by UniDoc on 2021/04/15 @ 23:59:54.