getReport (MException) - Get error message for exception
Syntax
msgString =
getReport(errRecord)
msgString = getReport(errRecord, type)
msgString = getReport(errRecord, type,
'hyperlinks', value)
Description
msgString =
getReport(errRecord) returns
a formatted message string, msgString,
that is based on the current error (or exception).
This exception is represented by an object errRecord of
the MException class. The message string returned
by getReport is the same as the error message
displayed by MATLAB when it throws this same exception.
msgString = getReport(errRecord, type) returns
a message string that either describes just the highest level error
(basic type),
or shows the error and the stack as well (extended type).
The type argument, when used, must be the
second argument in the input argument list. See Examples , below.
| type Option | Displayed Text |
| 'extended' | Display line number, error message, and cause and stack summary
(default) |
| 'basic' | Display line number and error message |
msgString = getReport(errRecord, type,
'hyperlinks', value) returns
a message string that either does or does not include active hyperlinks
to the failing lines in the code. See the table below for the valid
choices for value. The hyperlinks and value arguments, when used, must
be the third and fourth arguments in the input argument list.
| value Option | Action |
| 'on' | Display hyperlinks to failing lines (default) |
| 'off' | Do not display hyperlinks to failing lines |
| 'default' | Use the default for the Command Window to determine whether
or not to use hyperlinks in the error message |
Examples
Try calling the MATLAB surf function
without the required input argument. In the catch statement,
capture the error in an MException object, errRecord.
Then, use this object with getReport to retrieve
a basic error string:
try
surf
catch errRecord
rep = getReport(errRecord, 'basic')
end
rep =
Error using ==> surf at 50
Not enough input arguments.
Run the try-catch again, this time replacing 'basic' with 'extended':
In this case, the error message includes information from the stack:
rep = getReport(errRecord, 'extended')
rep =
Error using ==> surf at 50
Not enough input arguments.
Error in ==> getRep>getRep3 at 9
surf
Error in ==> getRep>getRep2 at 5
getRep3(option, state)
Error in ==> getRep at 2
getRep2(option, state)
See Also
try, catch, error, assert, MException, throw(MException), rethrow(MException), throwAsCaller(MException), addCause(MException), last(MException),
 | getqualitydesc | | getsampleusingtime (timeseries) |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit