Retrieve the last error number and text

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.




getlasterror() returns the last error that occurred in the current MuPAD® session, as a list of the error number and the error string.

After an error has occurred (whether visible or caught by traperror), getlasterror will return both the error number (as returned by traperror) and the error string.

In a MuPAD session where no errors occurred, getlasterror returns the list [0, ""]. This is also true after a call to reset().

    Note:   Note that the MuPAD library uses traperror itself and that getlasterror() may return errors that have been caught and properly handled by the library already. You should not use getlasterror to detect errors, use the return value of traperror instead!


Example 1

In a fresh session, getlasterror returns a list indicating "no errors yet":


After an error has been thrown, getlasterror returns the corresponding number and string:

Error: Singularity. [ln]

This includes errors not displayed because of traperror:

traperror(solve(a, b, c))


Return Values

List of an integer and a string

See Also

MuPAD Functions

Was this topic helpful?