MapleTrapError - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


MapleTrapError

trap a Maple error in external code

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MapleTrapError(kv, f, data, err)

Parameters

kv

-

kernel handle of type MKernelVector

f

-

C function pointer

data

-

pointer to any data

err

-

boolean flag set to true if an error occurs executing f

Description

• 

This function can be used in external code with OpenMaple or define_external.

• 

MapleTrapError attempts to execute the C function f(data). If a Maple error is raised at any time during execution of f, the function returns immediately after setting err to TRUE.

• 

This function can be used in OpenMaple to abort function calls when MapleRaiseError is invoked.

Examples

    #include "maplec.h"

    typedef struct {

       MKernelVector kv;

       ALGEB *args;

    } tryGuessArgs;

    void *tryGuess( void *data )

    {

    return (void*)MyGuessInput(((tryGuessArgs*)data)->kv,

                   ((tryGuessArgs*)data)->args);

    }

    ALGEB M_DECL MyGuessInput2( MKernelVector kv, ALGEB *args )

    {

    M_BOOL errorflag;

    ALGEB result;

    tryGuessArgs a;

    a.kv = kv;

    a.args = args;

    result = (ALGEB)MapleTrapError(kv,tryGuess,&a,&errorflag);

    if( errorflag ) {

        result = EvalMapleStatement(kv,"lasterror:");

        MapleALGEB_Printf(kv,"Caught error: %an",result);

        return( ToMapleBoolean(kv,FALSE) );

    }

    else {

        return( result );

    }

    }

Execute the external function from Maple.

withExternalCalling:

dllExternalLibraryNameHelpExamples:

errDefineExternalMyGuessInput2,dll:

err2.2,2.2

Caught error: "one argument expected"

false

(1)

err0,0

Caught error: "integer expected for M_INT parameter"

false

(2)

err0

Caught error: ["%1 is too small", 0]

false

(3)

err1

true

(4)

See Also

CustomWrapper

define_external

error

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples

traperror(deprecated)