« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Methods

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.

Examples

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


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.

Derives

Implements

  • Assignassign
  • Currentcurrent
  • Docname brief description definition
  • Lenlen
  • Newnew del construct destruct
  • Showshow look print scan
  • Startwith start stop join running

Back