Programming and Data Types    

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.

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 syntaxAmbiguous might be appropriate.

  Warnings Using Message Identifiers with lasterr