raise a Maple error in external code
MapleRaiseError1(kv, msg, arg1)
MapleRaiseError2(kv, msg, arg1, arg2)
kernel handle of type MKernelVector
type ALGEB objects
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",
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.
ALGEB M_DECL MyGuessInput( MKernelVector kv, ALGEB *args )
if( MapleNumArgs(kv,(ALGEB)args) != 1 )
MapleRaiseError(kv,"one argument expected");
n = MapleToM_INT(kv,args);
if( n <= 0 )
MapleRaiseError1(kv,"%1 is too small",args);
if( n > 1 )
MapleRaiseError1(kv,"%1 is too big",args);
return( ToMapleBoolean(kv,TRUE) );
Execute the external function from Maple.
Error, (in err) one argument expected
Error, (in err) integer expected for M_INT parameter
Error, (in err) -1 is too small
Error, (in err) 99 is too big
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
ALGEB r = ToMapleExpressionSequence(kv,2,
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
Download Help Document
What kind of issue would you like to report? (Optional)