AMPL_ERRORHANDLER#
- group AMPL_ERRORHANDLER
These fuctions provide error infos of the underlying AMPL interpreter.
Defines
-
AMPL_CALL(x)#
Helper macro to invoke an AMPL API call and report errors.
This macro evaluates an expression expected to return an AMPL_ERRORINFO pointer. If an error is returned, its message is printed to standard error.
Note
This macro does not terminate execution or free the error object.
- Parameters:
x – An expression returning
AMPL_ERRORINFO*
Typedefs
-
typedef struct AMPL_ErrorInfo AMPL_ERRORINFO#
-
typedef void (*ErrorHandlerCbPtr)(bool isWarning, const char *filename, int row, int offset, const char *message, void *errorHandler)#
Callback type for custom error and warning handling.
This callback can be registered to receive detailed information about errors and warnings produced by AMPL.
- Param isWarning:
True if the message is a warning, false if it is an error
- Param filename:
Source file where the issue occurred (may be NULL)
- Param row:
Line number in the source file
- Param offset:
Character offset within the line
- Param message:
Human-readable message
- Param errorHandler:
User-defined context pointer
Enums
-
enum AMPL_ERRORCODE#
Enumerates all possible error and exception types reported by AMPL.
These error codes classify the nature of errors returned by AMPL API calls and error handlers, ranging from syntax and runtime errors to licensing and infeasibility issues.
Values:
-
enumerator AMPL_EXCEPTION#
Generic exception.
-
enumerator AMPL_LICENSE_EXCEPTION#
Licensing-related error.
-
enumerator AMPL_FILE_IO_EXCEPTION#
File input/output error.
-
enumerator AMPL_UNSUPPORTED_OPERATION_EXCEPTION#
Unsupported or invalid operation.
-
enumerator AMPL_INVALID_SUBSCRIPT_EXCEPTION#
Invalid subscript or index usage.
-
enumerator AMPL_NO_DATA_EXCEPTION#
Missing or unavailable data.
-
enumerator AMPL_LOGIC_ERROR#
Logical error in model or API usage.
-
enumerator AMPL_RUNTIME_ERROR#
Runtime error during model execution.
-
enumerator AMPL_INVALID_ARGUMENT#
Invalid argument passed to an API function.
-
enumerator AMPL_OUT_OF_RANGE#
Argument value out of allowable range.
-
enumerator AMPL_STD_EXCEPTION#
Standard library exception.
-
enumerator AMPL_PRESOLVE_EXCEPTION#
Error during presolve phase.
-
enumerator AMPL_INFEASIBILITY_EXCEPTION#
Model infeasibility detected.
-
enumerator AMPL_EXCEPTION#
Functions
-
AMPL_ERRORCODE AMPL_ErrorInfoGetError(AMPL_ERRORINFO *error)#
Retrieve the error code associated with an error.
- Parameters:
error – Pointer to an AMPL_ERRORINFO instance
- Returns:
The corresponding AMPL_ERRORCODE
-
char *AMPL_ErrorInfoGetMessage(AMPL_ERRORINFO *error)#
Retrieve the human-readable error message.
- Parameters:
error – Pointer to an AMPL_ERRORINFO instance
- Returns:
Null-terminated string describing the error
-
int AMPL_ErrorInfoGetLine(AMPL_ERRORINFO *error)#
Retrieve the line number where the error occurred.
- Parameters:
error – Pointer to an AMPL_ERRORINFO instance
- Returns:
Line number, or -1 if unavailable
-
int AMPL_ErrorInfoGetOffset(AMPL_ERRORINFO *error)#
Retrieve the character offset within the line.
- Parameters:
error – Pointer to an AMPL_ERRORINFO instance
- Returns:
Character offset, or -1 if unavailable
-
char *AMPL_ErrorInfoGetSource(AMPL_ERRORINFO *error)#
Retrieve the source text associated with the error.
This may contain the line of AMPL code that triggered the error.
- Parameters:
error – Pointer to an AMPL_ERRORINFO instance
- Returns:
Null-terminated source string, or NULL if unavailable
-
int AMPL_ErrorInfoFree(AMPL_ERRORINFO **error)#
Free an AMPL_ERRORINFO object.
This function releases all resources associated with the error and sets the pointer to NULL.
- Parameters:
error – Address of an AMPL_ERRORINFO pointer
- Returns:
0 on success, non-zero on failure
-
AMPL_CALL(x)#