MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Object Constructor

Any code that detects an error and throws an exception must also construct an
MException object in which to record and transfer information about the error. The
syntax of the MException constructor is

ME = MException(identifier, message)

where identifier is a MATLAB message identifier on page 26-8 of the form

component:mnemonic

that is enclosed in single quotes, and message is text, also enclosed in single quotes, that
describes the error. The output ME is the resulting MException object.

If you are responding to an exception rather than throwing one, you do not have to
construct an MException object. The object has already been constructed and populated
by the code that originally detected the error.

Properties of the MException Class


The MException class has several properties. Each of these properties is implemented as
a field of the structure that represents the MException object. Each of these properties
is described in the sections below and referenced in the sections on “Respond to an

26 Error Handling

Free download pdf