Table of Contents

Name

BeginBlock, EndBlock, (Un)RegisterPointer, (Un)RegisterStream, RaiseException, RestoreUserContext - exception handling

Synopsis


#include <exception.h>
extern int BeginBlock (void);
extern int EndBlock (void);
extern int RegisterPointer (void * ptr);
extern int UnRegisterPointer (void * ptr);
extern int RegisterStream (stream fptr);
extern int UnRegisterStream (stream fptr);
extern void RaiseException (int errNumber);
extern void RestoreUserContext (void);

DescriptionException handling is an alternative error handling mechanism
in NEMO, much like exception handling in C++.  NEMO can optionally be compiled
(see options.h or the autoconf mechanism, see installation manual) such
that that main trouble points in NEMO's libraries (e.g.  allocate.c and stropen.c)
can use this mechanism. It has the  advantage that programs written using
the NEMO library can recover from  errors.   Users using NEMO routines can
designate blocks of code that will recover from any NEMO error, transferring
control to a user defined exception  handler.  A BeginBlock call marks the
beginning of a block and an EndBlock  marks the end of a block. Every BeginBlock
is matched to the closest  EndBlock. Blocks may be nested by nested BeginBlock/EndBlock
 pairs, but the effect is the same as if only the outermost  BeginBlock/EndBlock
pair was present. We plan to implement nested  blocks, with nested recovery,
in future versions.   BeginBlock marks the beginning of a block of code
and the point of  return from exception handler.  EndBlock turns off exception
handling for the block begun with the last BeginBlock; does cleanup of
memory and streams.  RegisterPointer  marks allocated memory as resource
to be freed when an error occurs.   UnRegisterPointer  unmarks a  resource
- for example,  when it is freed.  RegisterStream and UnRegisterStream  ....
bla bla ..  RaiseException raises an exception when an irretrievable error
occurs. It transfers control to exception handling mechanism.  RestoreUserContext
restores the context after exception handling is done. 
ExamplesIn the following
example a lower level routine is entered ....   

See Also

error(3NEMO) , getparam(3NEMO) ,

Files

src/kernel/cores/exception.c

Author

N.S. Amarnath

Update History


dec-2001    introduced in NEMO    NAS


Table of Contents