MaplePushErrorProc - Maple Help

Online Help

All Products    Maple    MapleSim


MaplePushErrorProc

push an error handling procedure

MaplePopErrorProc

pop an error handling procedure

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MaplePushErrorProc(kv, void (M_DECL *errorproc)( char *msg, void *d), void *data )

MaplePopErrorProc(kv)

Parameters

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

Description

• 

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.  The value of data will be passed to errorproc if an exception occurs.

• 

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.

Examples

#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