/**************************************************************************** ** ** This file is part of GAP, a system for computational discrete algebra. ** ** Copyright of GAP belongs to its developers, whose names are too numerous ** to list here. Please refer to the COPYRIGHT file for details. ** ** SPDX-License-Identifier: GPL-2.0-or-later ** ** This file declares functions for raising user errors and interacting ** with the break loop. **
*/
#ifndef GAP_ERROR_H #define GAP_ERROR_H
#include"system.h" #include"intobj.h"
/**************************************************************************** ** *F RegisterBreakloopObserver( <func> ) ** ** Register a function which will be called when the break loop is entered ** and left. Function should take a single Int argument which will be 1 when ** break loop is entered, 0 when leaving. ** ** Note that it is also possible to leave the break loop (or any GAP code) ** by longjmping. This should be tracked with RegisterThrowObserver.
*/
typedefvoid (*intfunc)(Int);
Int RegisterBreakloopObserver(intfunc func);
/**************************************************************************** ** *F OpenErrorOutput() . . . . . . . open the file or stream assigned to the ** ERROR_OUTPUT global variable defined in ** error.g, or "*errout*" otherwise
*/
UInt OpenErrorOutput(TypOutputFile * output);
/**************************************************************************** ** *F ErrorMayQuit( <msg>, <arg1>, <arg2> ) . print, enter break loop and quit ** no option to return anything.
*/ void ErrorMayQuit(constChar * msg, Int arg1, Int arg2) NORETURN;
/**************************************************************************** ** *F ErrorMayQuitNrArgs( <narg>, <actual> ) . . . . wrong number of arguments
*/ void ErrorMayQuitNrArgs(Int narg, Int actual) NORETURN;
/**************************************************************************** ** *F ErrorMayQuitNrAtLeastArgs( <narg>, <actual> ) . . . not enough arguments
*/ void ErrorMayQuitNrAtLeastArgs(Int narg, Int actual) NORETURN;
/**************************************************************************** ** *F ErrorReturnObj( <msg>, <arg1>, <arg2>, <msg2> ) . . print and return obj
*/
Obj ErrorReturnObj(constChar * msg, Int arg1, Int arg2, constChar * msg2);
/**************************************************************************** ** *F ErrorReturnVoid( <msg>, <arg1>, <arg2>, <msg2> ) . . . print and return
*/ void ErrorReturnVoid(constChar * msg, Int arg1, Int arg2, constChar * msg2);
/**************************************************************************** ** *F RequireArgumentEx( <funcname>, <op>, <argname>, <msg>) ** ** Raises an error via ErrorMayQuit with an error message of this form: ** funcname: <argname> msg (not a %s) ** Here, %s is replaced by a brief text which describes the type or content ** of <op>. ** ** If funcname is 0, then 'funcname: ' is omitted from the message. ** If argname is 0, then '<argname> ' is omitted from the message. ** ** All string arguments are copied to a buffer before a garbage collection ** may be triggered, hence it is safe to pass pointers into string objects.
*/ void RequireArgumentEx(constchar * funcname,
Obj op, constchar * argname, constchar * msg) NORETURN;
/**************************************************************************** ** *F RequireNonnegativeSmallInt
*/ #define RequireNonnegativeSmallInt(funcname, op) \
RequireArgumentCondition(funcname, op, IS_NONNEG_INTOBJ(op), \ "must be a non-negative small integer")
/**************************************************************************** ** *F ErrorBoundedInt *F RequireBoundedIntEx, RequireBoundedInt ** ** Require a small integer n satisfying min <= n <= max
*/ void ErrorBoundedInt(constchar * funcname,
Obj op, constchar * argname, int min, int max) NORETURN;
#define RequireBoundedIntEx(funcname, op, argname, min, max) \ do { \ if (!(IS_INTOBJ(op) && min <= INT_INTOBJ(op) && \
INT_INTOBJ(op) <= max)) { \
ErrorBoundedInt(funcname, op, argname, min, max); \
} \
} while (0)
/**************************************************************************** ** *F RequireSameLength ** ** This one is a bit different from the other Require functions, as it takes ** two operands into account.
*/ #define RequireSameLength(funcname, op1, op2) \
CheckSameLength(funcname, #op1, #op2, op1, op2)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.