Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 869531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:19:19+00:00 2026-05-15T10:19:19+00:00

When creation a MATLAB exception (MException object) or printing a warning or error message,

  • 0

When creation a MATLAB exception (MException object) or printing a warning or error message, MATLAB lets you supply a message ID that defines the except you’re throwing.

The message ID is in the format:

component:mnemonic

For example, MATLAB’s own undefined variable message ID is:

MATLAB:dispatcher:nameConflict

So when you use exceptions in your own code, what do you use for a message ID? Do you reuse MATLAB’s default ones? Make up your own? What do you use for the component and mnemonic strings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:19:20+00:00Added an answer on May 15, 2026 at 10:19 am

    I generally follow this pattern for error (or warning) message identifiers, where things in parentheses may or may not be present:

    (className):(parentFunction):functionWhereErrorOccurs:descriptiveMnemonic
    

    The components are:

    • className: The name of the class, if the function where the error occurs is a method/constructor.

    • parentFunction: If the function where the error occurs is a subfunction in an m-file or a nested function, this would be the primary m-file function or the parent of the nested function, respectively. You could therefore have multiple parentFunction components.

    • functionWhereErrorOccurs: The name of this component is pretty self-explanatory. 😉

    • descriptiveMnemonic: I stress descriptive. For example inputError doesn’t really tell me anything, but notEnoughInputs makes it clear that I didn’t pass enough arguments. I always use lower camel case for the mnemonic, where the first letter of a word is capitalized except for the very first word.

    The className and parentFunction components could be considered somewhat redundant, since the stack property of the MException class already identifies a complete path to the parent m-file and the line number of the error. However, one of the purposes of a message identifier is that it allows you to uniquely identify an error for purposes other than just hunting down the source of the error.

    Let’s say you have a function myFcn and a class myClass that overloads myFcn. If you make an error message identifier for the first one be myFcn:maxIterationsReached and an error message identifier for the second one be myClass:myFcn:maxIterationsReached, this would allow you to, for example, set a breakpoint with DBSTOP that halts execution only when this error is produced by myClass\myFcn and not myFcn. Likewise, unique warning message identifiers are useful in that you can specifically choose to ignore warnings from specific functions while letting others be displayed.

    Additionally, you could also include components in the identifier indicating that the function where the error occurs is located in a package folder or a private folder (but this might make for a rather long identifier).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Object creation is a bottleneck in my application. I think that adding more threads
I noticed that creation of a MapView object takes a long time. It is
I noticed that the first creation of an image from an uri takes pretty
We can restrict the creation of object of a class by making its constructor
Code for creation of cell arrays taken from: Array of Matrices in MATLAB [Thank
I have this account creation email that is sent out to anyone who is
EDIT : the function creation was missing, sorry about that I have a T-SQL
To make certain form creation easier, we use a modified Formview control that is
Through some random object creation today I came across this neat little shortcut for
I know that the creation date isn't stored in the filesystem itself, but I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.