Main Content

Exception Handling

Capture data on errors

Any MATLAB®  code that detects an error and throws an exception constructs an MException object. MATLAB can throw either predefined exceptions or exceptions that you construct.

Functions

try, catchExecute statements and catch resulting errors
MExceptionCapture error information
addCauseRecord additional causes of exception
addCorrectionProvide suggested fix for exception
getReportGet error message for exception
MException.lastReturn last uncaught exception
rethrowRethrow previously caught exception
throwThrow exception
throwAsCallerThrow exception as if occurs within calling function
matlab.lang.correction.AppendArgumentsCorrectionCorrect error by appending missing input arguments
matlab.lang.correction.ConvertToFunctionNotationCorrectionCorrect error by converting to function notation
matlab.lang.correction.ReplaceIdentifierCorrectionCorrect error by replacing identifier in function call

Topics