MapleTrapError - trap a Maple error in external code
|
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
|
|
•
|
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.
|
|
|
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:");
|
MaplePrintf(kv,"Caught error: %sn",MapleToString(kv,result));
|
return( ToMapleBoolean(kv,FALSE) );
|
}
|
else {
|
return( result );
|
}
|
}
|
|
|
Execute the external function from Maple.
>
|
|
>
|
|
>
|
|
>
|
|
Caught error: one argument expected
| |
| (1) |
>
|
|
Caught error: integer expected for M_INT parameter
| |
| (2) |
>
|
|
Caught error: %1 is too small
| |
| (3) |
>
|
|
| (4) |
|
|
Download Help Document
Was this information helpful?