lasterror
Returns a struct describing the most recent error (obsolete).
Category: Programming > Functions
Syntax
s = lasterror
Returns the last error as a struct.
Description
lasterror packages the information of the most recent error as a struct. It is kept for old programs; in new code, catch the error with catch err and work with the MException object err, which also supports rethrow and getReport.
Output arguments
s- Struct with fields
message,identifierandstack.
Example
Fields of the last error
try
error('Demo:fail', 'boom %d', 2);
catch
end
s = lasterror;
s.message
s.identifier
Output
ans = 'boom 2'
ans = 'Demo:fail'