MaplePushErrorProc
push an error handling procedure
MaplePopErrorProc
pop an error handling procedure
Calling Sequence
Parameters
Description
Examples
MaplePushErrorProc(kv, void (M_DECL *errorproc)( char *msg, void *d), void *data )
MaplePopErrorProc(kv)
kv
-
kernel handle of type MKernelVector
errorproc
an error handling routine that accepts two arguments, msg and d
data
a value to be passed to errorproc
The MaplePushErrorProc and MaplePopErrorProc functions are used to manage exception handling routines.
Maple maintains a stack of error handling routines. When an exception is raised, each function on the stack will be called. Two arguments are passed to these functions: the first, msg, is the exception being raised and the second, d, is the value of data that is given when MaplePushErrorProc is called.
MaplePushErrorProc adds the function errorproc to the top of the error handling stack.
If an exception occurs, the kernel will call errorproc, passing it the exception message as msg and the value of data as d. The kernel will remove errorproc from the error handling stack. The errorproc should be written so that no new exception will be raised during that call.
MaplePopErrorProc removes an error handling procedure from the stack of error handling routines.
It is important that error handling routines are removed from the stack when they are no longer needed.
#include "maplec.h"
void M_DECL FreeMemoryBuffer( char *error, void *data )
{
free( data );
}
ALGEB M_DECL DoABunchOfWork( MKernelVector kv, ALGEB *args )
int *buffer = (int*)malloc( 1000 );
MaplePushErrorProc( kv, FreeMemoryBuffer, buffer );
CallAFunctionThatMightThrowAnException( kv, args, buffer );
MaplePopErrorProc( kv );
free( buffer );
return ToMapleNULL( kv );
See Also
CustomWrapper
define_external
eval
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
Download Help Document