Skip to Main Content Skip to Search
Product Documentation

last (MException) - Last uncaught exception

Syntax

exception = MException.last
MException.last('reset')

Description

exception = MException.last displays the contents of the MException object representing your most recent uncaught error. This is a static method of the MException class; it is not a method of an MException instance.

MException.last('reset') sets the identifier and message properties of the exception retreived by MException.last to the empty string, the stack property to a 0-by-1 structure, and cause property to an empty cell array.

MException.last is not set if an exception is caught by a try-catch statement.

Examples

This example displays the last error that was caught during this MATLAB session:

A = 25;
A(2)
??? Index exceeds matrix dimensions.

MException.last
ans =

	MException object with properties:

    identifier: 'MATLAB:badsubscript'
       message: 'Index exceeds matrix dimensions.'
         stack: [0x1 struct]
         cause: {}

See Also

addCause(MException) | assert | catch | error | getReport(MException) | MException | rethrow(MException) | throw(MException) | throwAsCaller(MException) | try

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS