try
#define try
Start an exception try
block.
catch
#define catch(...)
Start an exception catch
block, catching any objects listed in ...
as the first name given. To catch any exception object leave argument list empty other than caught variable name.
#define throw
throw(E, F, ...)
Throw exception object E
with format string F
and arguments ...
.
exception_signals
void exception_signals(void);
Register the standard C signals to throw corresponding exceptions.
exception_object
void exception_object(void);
Retrieve the current exception object.
exception_message
void exception_message(void);
Retrieve the current exception message.
Usage
var x = new(Table, String, Int);
set(x, $S("Hello"), $I(1));
set(x, $S("World"), $I(2));
try {
get(x, $S("Missing"));
} catch (e in KeyError) {
println("Got Exception: %$", e);
}
Exception Object
The Exception
type provides an interface to the Cello Exception System. One instance of this type is created for each Thread
and stores the various bits of data required for the exception system. It can be retrieved using the current
function, although not much can be done with it.
Exceptions are available via the try
, catch
and throw
macros. It is important that the catch
part of the exception block is always evaluated otherwise the internal state of the exception system can go out of sync. For this reason please never use return
inside a try
block.
The exception_signals
method can be used to register some exception to be thrown for any of the standard C signals.
To get the current exception object or message use the exception_message
or exception_object
methods.
$
alloc
dealloc
cast
cmp
eq
neq
gt
lt
ge
le
copy
hash
hash_data
size
swap
assign
current
name
brief
description
definition
len
new
del
construct
destruct
show
look
print
scan
with
start
stop
join
running