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

Online Help

All Products    Maple    MapleSim


MapleRaiseError

raise a Maple error in external code

MapleRaiseError1

raise a Maple error in external code

MapleRaiseError2

raise a Maple error in external code

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MapleRaiseError(kv, msg)

MapleRaiseError1(kv, msg, arg1)

MapleRaiseError2(kv, msg, arg1, arg2)

Parameters

kv

-

kernel handle of type MKernelVector

msg

-

error message

arg1, arg2

-

type ALGEB objects

Description

• 

These functions can be used in external code with OpenMaple or define_external.

• 

These functions raise the Maple error described by msg, equivalent to the Maple command error(msg,arg1,arg2);.

• 

If used as part of ExternalCalling, execution is returned back to Maple (or to the exception handler installed by a try command).  If used as part of OpenMaple, the errorCallBack is invoked, and execution continues at the next statement. The OpenMaple behavior can be changed to interrupt computation at an error invoked by MapleRaiseError when the external function is launched via MapleTrapError.

• 

The character string msg can contain wildcards of the form %N, where N is a non-zero integer. These wildcards are replaced by the extra argument, arg1 or arg2, before displaying the message. If %-N is specified, then the optional argument is displayed with the appropriate suffix, st, nd, rd, or th, appended. For example, consider the following command.

MapleRaiseError2(kv, "the %-1 argument, '%2', is not valid",

    ToMapleInteger(i), args[i]);

  

This, if invoked, raises the error, "the 4th argument, 'foo', is not valid", assuming i=4, and args[i] is set to the Maple name, foo. For more information, see error. The only option not allowed is %0 since the function cannot determine the number of unparsed optional arguments.

Examples

    #include "maplec.h"

    ALGEB M_DECL MyGuessInput( MKernelVector kv, ALGEB *args )

    {

    M_INT n;

    if( MapleNumArgs(kv,(ALGEB)args) != 1 )

        MapleRaiseError(kv,"one argument expected");

    n = MapleToM_INT(kv,args[1]);

    if( n <= 0 )

        MapleRaiseError1(kv,"%1 is too small",args[1]);

    if( n > 1 )

        MapleRaiseError1(kv,"%1 is too big",args[1]);

    return( ToMapleBoolean(kv,TRUE) );

    }

Execute the external function from Maple.

withExternalCalling&colon;

dllExternalLibraryNameHelpExamples&colon;

errDefineExternalMyGuessInput&comma;dll&colon;

err

Error, (in err) one argument expected

err0&comma;0

Error, (in err) integer expected for M_INT parameter

err1

Error, (in err) -1 is too small

err99

Error, (in err) 99 is too big

err1

true

(1)

Note: Because the examples above were executed within Maple,

execution terminated when the first error was raised.  This is

not the case when MapleRaiseError is called directly from an

OpenMaple program.  Consider the following code executed after

starting OpenMaple.

    ALGEB r = ToMapleExpressionSequence(kv,2,

        ToMapleFloat(kv,2.2),ToMapleFloat(kv,2.2));

    MyGuessInput(kv,(ALGEB*)r);

Since MapleRaiseError does not stop execution, the one call

produces three errors.

 Error, one argument expected

 Error, integer expected for M_INT parameter

 Error, 2.20000000000000016 is too small

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples