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

  • Home
  • SEARCH
  • 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 3982690
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:33:29+00:00 2026-05-20T05:33:29+00:00

Sometimes the exception type is unique enough to indicate the exact issue, such as

  • 0

Sometimes the exception type is unique enough to indicate the exact issue, such as an ArgumentOutOfRangeException. Othertimes, the exception is more general and could be thrown for several reasons. In this scenario, it seems the only additional information is found in the exception message property.

In my current circumstance, I am getting a CommunicationException which throws the error message:

The maximum message size quota for incoming messages (65536) has been exceeded

As multiple different errors may be thrown via the CommunicationException, is it bad practice to use the message property to determine the cause, like so:

catch (CommunicationException ex)
{
    if (Regex.IsMatch(ex.Message, "The maximum message size quota for incoming messages .* has been exceeded"))
    {
        // handle thrown exception
    }
    throw;
}

Will these messages be constant and reliable on all systems? Are there any other considerations, such as localization?

Conclusion:

My scenario with the ‘CommunicationException’ was a bad example, as I later realized that there was a QuotaExceededException in the InnerException property. Thanks to the responses, I knew to look for any data that existed in the exception to indicate the exact cause. In this case, it was the InnerException property.

In terms of the question regarding whether or not the message property should be used to determine the cause, it seems to be the general consensus that it should be avoided unless there is no alternative. The message property value may not remain constant over varying systems due to localization.

  • 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-20T05:33:30+00:00Added an answer on May 20, 2026 at 5:33 am

    IMHO magic string solutions should always be a last resort.

    Are you sure you can’t resolve the type of the error from the additional properties on the CommunicationException object:

    http://msdn.microsoft.com/en-us/library/system.servicemodel.communicationexception.aspx

    .. or are you getting an InnerException that is more useful?

    In answer to the last question, many .net exception messages are localized. So you might run into problems there if this software is going to be deployed widely. See the following question for a possible workaround for this:

    Exception messages in English?

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

Sidebar

Related Questions

Why does the following code sometimes causes an Exception with the contents CLIPBRD_E_CANT_OPEN: Clipboard.SetText(str);
If my code throws an exception, sometimes - not everytime - the jsf presents
Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?
I really hate sometimes how IDictionary<TKey, TValue> [key] will throw an exception if the
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
Sometimes I get exception in my production environment: Process information Process ID: 3832 Process
I'm baffled. My site randomly throws the following error: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException'
I'm using StringTemplate to generate some xml files from datasets. Sometimes I have more
I have a windows service that is, intermittently, throwing an exception that sometimes kills
Sometimes I get an exception like this: This method cannot be translated into a

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.