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


int MLError(MLINK link)
returns a value identifying the last error to occur on link. MLError() returns MLEOK if no error has occurred since the previous call to MLClearError().
  • MLError() can return the following values:
MLEOKeverything is OK
MLEDEADlink died
MLEGBADinconsistent data read
MLEGSEQMLGet() function called out of sequence
MLEPBTKMLPutNext() passed a bad token
MLEPSEQMLPut() function called out of sequence
MLEPBIGMLPutData() given too much data
MLEOVFLmachine number overflow
MLEMEMout of memory
MLEACCEPTfailure to accept socket connection
MLECONNECTa deferred connection is still unconnected
MLEPUTENDPACKETunexpected or missing call of MLEndPacket()
MLENEXTPACKETMLNextPacket() called while the current packet has unread data
MLEUNKNOWNPACKETMLNextPacket() read in an unknown packet head
MLEGETENDPACKETunexpected end of packet
MLEABORTa put or get was aborted before affecting the link
MLECLOSEDthe other side of the link closed the connection (you may still receive undelivered data)
MLEINITthe MathLink environment was not initialized
MLEARGVinsufficient arguments to open the link
MLEPROTOCOLprotocol unavailable
MLEMODEmode unavailable
MLELAUNCHlaunch unsupported
MLELAUNCHAGAINcannot launch the program again from the same file
MLELAUNCHSPACEinsufficient space to launch the program
MLENOPARENTno parent available for connection
MLENAMETAKENthe linkname was already in use
MLENOLISTENthe linkname was found not to be listening
MLEBADNAMEthe linkname was missing or not in the proper form
MLEBADHOSTthe location was unreachable or not in the proper form
MLELAUNCHFAILEDthe program failed to launch because a resource or library was missing
MLELAUNCHNAMEthe launch failed because the program could not be found
MLEPSCONVERTunable to convert from given character encoding to link encoding
MLEGSCONVERTunable to convert from link encoding to requested encoding
MLEPDATABADcharacter data in given encoding incorrect
  • MLError() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* send the integer 10 to a link */

void f(MLINK lp)
    if(! MLPutInteger(lp, 10))
        /* check the possible errors */
            case MLEDEAD:
                /* the link died unexpectedly */
            case MLECLOSED:
                /* the other side closed the link */
            case MLEOK:
                /* no error occurred */
                /* ... */