getReport

Returns the text describing an exception.

Category: Programming > Programming Utilities

Syntax

report = getReport(ME)

Returns the error report of the exception ME as a character vector.

Description

The report is what the command window would print for an uncaught error, which makes it a convenient string to log or show in a dialog. In MATLAB it can include the location of the error and the causes attached with addCause.

Input arguments

ME
An MException object, typically caught with catch ME.

Output arguments

report
Character vector with the error text.

Example

Reporting a caught error

try
    error('data:range', 'Value %d is out of range', 12)
catch ME
    r = getReport(ME)
end
Output
r = 
    'Error using ex
     Value 12 is out of range'

Notes

MatLivre returns only the message text of the exception, without location or cause information.

See also

MException try, catch addCause error lasterr