Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Errors


NAME

Errors - general interface for error handlers

SYNOPSIS

CONST debug = 0;
CONST message = 1;
CONST warning = 2;
CONST error = 3;
CONST fatal = 4;
CONST bug = 5;
CONST nkinds = 6;
TYPE Kind = SHORTINT; (* debug..bug *)
VAR kindText: ARRAY nkinds OF ARRAY 12 OF CHAR;
TYPE Handler = PROCEDURE (event: Events.Event; kind: Kind);
TYPE HandlerSet = POINTER TO HandlerSetRec;
TYPE HandlerSetRec = RECORD (Disciplines.ObjectRec) END;
TYPE WriteProcedure = PROCEDURE (s: Streams.Stream; event: Events.Event);
VAR null: HandlerSet; (* empty handler set *)


PROCEDURE CreateHandlerSet(VAR hs: HandlerSet); PROCEDURE InstallHandler(hs: HandlerSet; kind: Kind; handler: Handler); PROCEDURE AssignWriteProcedure(eventType: Events.EventType; write: WriteProcedure); PROCEDURE Write(s: Streams.Stream; event: Events.Event); PROCEDURE CatchEvent(hs: HandlerSet; kind: Kind; type: Events.EventType);

DESCRIPTION

Errors defines a general interface for event-driven error handling. To allow some flexibility in the sort of reaction, a classification of events is introduced:
debug
Intended for events which are convenient for debugging or tracing.
message
Suitable for notification events.
warning
Intended for notifications which indicate a problem or errors which do not lead to failures.
error
Indicates a failure which allows further processing.
fatal
Intended for serious failures which should lead to process termination.
bug
Suitable for programming errors which are comparable to runtime faults. Handlers of bug events are expected to abort execution.

A handler set defines a handler for each kind of events. CreateHandlerSet creates a new handler set and initializes it to the empty set. By default, all events are ignored (empty handler). InstallHandler installs a handler for the given class of events for hs.

Many events contain additional components which contain interesting information beyond the simple text of the message component. AssignWriteProcedure allows to attach a specific write procedure to an event type. Write calls either a previously assign write procedure or, in the default case, copies event.message to s.

CatchEvent associates kind with the given event type and causes the appropiate handler of hs to be called if type is raised.

SEE ALSO

Conclusions
defines a standard handler set
Events
general event handling

Edited by: borchert, last change: 2003/07/10, revision: 1.3, converted to HTML: 2003/07/10

Oberon || Library || Module Index || Search Engine || Definition || Module