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 8855869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:13:58+00:00 2026-06-14T14:13:58+00:00

This is my current exception handling code. Take especial note of the line throw

  • 0

This is my current exception handling code.

Take especial note of the line throw e; marked with ***.

try
{
  //some code that could cause exception
}
catch (FaultException e) //first catch a particular type of exception only
{
  if (Regex.IsMatch(e.Message, "something")) //satisfying a particular condition
  {
    Console.WriteLine("Particular exception occurred.");
    return;
  }
  else
    throw e; // <-- *** Problem! Not getting caught by the "catch" below.
}
catch (Exception e) //catch all other exceptions
{
  Console.WriteLine("General exception ocurred");
  return;
}

The problem is this: If the throw e; // <-- *** occurs, it is not getting caught by the final catch. Instead, the app just crashes as if the exception was not handled.

How can this be fixed in the simplest possible way?

You see in the first catch that I’m only interested in actually handling FaultException exceptions satisfying a particular condition, but leave all others (both FaultException exceptions not satisfying the condition and exceptions that are not FaultException) to the final catch. Unfortunately, this is not working properly.

I’m on .NET 4.

  • 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-06-14T14:13:59+00:00Added an answer on June 14, 2026 at 2:13 pm

    Only one catch block is executed per try block.

    I would rewrite the catch block as:

    catch (Exception e)
    {
        if (e is FaultException && Regex.IsMatch(e.Message, "something"))
        {
            ....
        }
        else // all other exceptions
        {
            ....
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
How do I log inner exception with Log4NET? This is my current conversion pattern:
We have this current database which we need to replace some tables by anther
I am having a bit of difficulty with this current code I have set
As a beginner in Ocaml, I have this current working code: ... let ch_in
Like this: Cursor.Current = Cursors.WaitCursor; try { . . . } finally { Cursor.Current
For some user controls, I have this binding: AppLanguage={Binding Path=ApplicationLanguage, Source={x:Static Application.Current}} This works
I am handling errors via my global.asax in this method: Dim CurrentException As Exception
Exception handling (EH) seems to be the current standard, and by searching the web,
Enterprise Library 5.0 Exception Handling includes the Wrap Handler. This wraps an exception in

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.