Programming Previous page   Next Page

Message Identifiers

A message identifier is a tag that you attach to an error or warning statement that makes that error or warning uniquely recognizable by MATLAB. You can use message identifiers with error reporting to better identify the source of an error, or with warnings to control any selected subset of the warnings in your programs. See the following topics for more information on how message identifiers are used:

Identifier Format

The message identifier is a string that specifies a component and a mnemonic label for an error or warning. A simple identifier looks like this:

Some examples of message identifiers are

Both the component and mnemonic fields must adhere to the following syntax rules:

There is no length limitation to either field.

Component Field

The component field of a message identifier specifies a broad category under which various errors and warnings may be generated. Common components are a particular product or toolbox name, such as MATLAB or Control, or perhaps the name of your company, such as TechCorp in the example above.

You can also use this field to specify a multilevel component. The statement below has a three-level component followed by a mnemonic label:

One purpose of the component field is to enable you to guarantee the uniqueness of each identifier. Thus, while MATLAB uses the identifier MATLAB:divideByZero for its 'Divide by zero' warning, you could reuse the divideByZero mnemonic by using your own unique component. For example,

Mnemonic Field

The mnemonic field is a string normally used as a tag relating to the particular message. For example, when reporting an error resulting from the use of ambiguous syntax, a mnemonic such as ambiguousSyntax might be appropriate.

Previous page  Regenerating an Error Using Message Identifiers with lasterr Next page

© 1994-2005 The MathWorks, Inc.