lasterr
Returns or sets last recorded error message.
📝Syntax
msg = lasterr()
[msg, id] = lasterr()
previous = lasterr(msg)
previous = lasterr(msg, id)
📥Input Arguments
Parameter Description
msg error message: character vector or string scalar.
id error identifier: character vector or string scalar.
📤Output Arguments
Parameter Description
msg last error message: character vector.
id last error identifier: character vector.
📄Description

msg = lasterr() returns the message of the last recorded error.

[msg, id] = lasterr() also returns the error identifier.

lasterr(msg) and lasterr(msg, id) set the last error message (and identifier), returning the previous message.

💡Examples
try
  error('MyPkg:boom', 'exploded');
catch
end
[msg, id] = lasterr()
🔗See Also
lasterrorerror
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub