This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Error and Interrupt Handling

When you are putting and getting data via MathLink various kinds of errors can occur. Whenever any error occurs, MathLink goes into a completely inactive state, and all MathLink functions you call will return 0 immediately.
intMLError(MLINK link)return a number identifying the current error, or 0 if none has occurred
char*MLErrorMessage(MLINK link)
return a character string describing the current error
int MLClearError(MLINK link)clear the current error, returning MathLink if possible to an active state

Handling errors in MathLink programs.

When you do complicated operations, it is often convenient to check for errors only at the end. If you find that an error occurred, you must then call MLClearError() to activate MathLink again.
int MLNewPacket(MLINK link)skip to the end of the current packet

Clearing out the remains of a packet.

After an error, it is common to want to discard the remainder of the packet or expression that you are currently processing. You can do this using MLNewPacket().
In some cases, you may want to set it up so that if an error occurs while you are processing particular data, you can then later go back and reprocess the data in a different way. You can do this by calling MLCreateMark() to create a mark before you first process the data, and then calling MLSeekMark() to seek back to the mark if you need to reprocess the data. You should not forgot to call MLDestroyMark() when you have finally finished with the data—otherwise MathLink will continue to store it.
intMLAborta global variable set when a program set up by Install is sent an abort interrupt

Aborting an external program.

If you interrupt Mathematica while it is in the middle of executing an external function, it will typically give you the opportunity to try to abort the external function. If you choose to do this, what will happen is that the global variable MLAbort will be set to 1 inside your external program.
MathLink cannot automatically back out of an external function call that has been made. So if you have a function that can take a long time, you should explicitly check MLAbort every so often, returning from the function if you find that the variable has been set.