addCause
Add cause to MException.
📝Syntax
ME = addCause(ME, causeException)
ME = ME.addCause(causeException)
📥Input Arguments
Parameter Description
ME a scalar MException object.
causeException a scalar MException object to add as a cause.
📤Output Arguments
Parameter Description
ME a new MException object containing the additional cause.
📄Description

addCause returns a new MException object with causeException appended to the cause property.

The original MException object is not modified.

💡Examples
errID = 'MYFUN:BadIndex';
msg = 'Unable to index into array.';
baseException = MException(errID, msg);
causeException = MException('MYFUN:BadSubscript', 'Index must be positive.');
newException = baseException.addCause(causeException)
errID = 'MYFUN:BadIndex';
msg = 'Unable to index into array.';
baseException = MException(errID, msg);
newException = addCause(baseException, baseException)
newException.cause{1}
🔗See Also
MExceptionaddCorrectiongetReportthrow
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub