You can also use this field to specify a multilevel component. The following statement has
a three-level component followed by a mnemonic label:
TechCorp:TestEquipDiv:Waveform:obsoleteSyntax
The component field enables you to guarantee the uniqueness of each identifier. Thus,
while the internal MATLAB code might use a certain warning identifier like
MATLAB:InconsistentDataType, that does not preclude you from using the same
mnemonic, as long as you precede it with a unique component. For example,
warning('TechCorp:InconsistentDataType', ...
'Value %s is inconsistent with existing properties.' ...
sprocketDiam)
Mnemonic Field
The mnemonic field is normally used as a tag relating to the particular message. For
example, when reporting an error resulting from the use of ambiguous syntax, a simple
component and mnemonic such as the following might be appropriate:
MATLAB:ambiguousSyntax
Message Identifiers in an MException Object
When throwing an exception, create an appropriate identifier and save it to the
MException object at the time you construct the object using the syntax
ME = MException(identifier, text)
For example,
ME = MException('AcctError:NoClient', ...
'Client name not recognized.');
ME.identifier
ans =
AcctError:NoClient
When responding to an exception, you can extract the message identifier from the
MException object as shown here. Using the surf example again,
try
surf
catch ME
id = ME.identifier
Capture Information About Exceptions