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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:27:11+00:00 2026-06-11T23:27:11+00:00

I am having a code function that has two catch blocks. Am posting the

  • 0

I am having a code function that has two catch blocks. Am posting the code below:

public void UpdateGroup(String strSiteID, String strGroup,  int row)
        {
            try
            {
                Console.WriteLine("UpdateGroup");
                Excel1.MWMClient.MWMServiceProxy.Group group = new Excel1.MWMClient.MWMServiceProxy.Group();
                group.name = "plumber";
                group.description = "he is a plumber";              
                Console.WriteLine(groupClient.UpdateGroup(strSiteID, group));
                ExcelRecorder(0, null, null, row);
            }
            catch (System.ServiceModel.FaultException<DefaultFaultContract> ex)
            {
                ExcelRecorder(ex.Detail.ErrorCode, ex.Detail.Message, ex.Message, row);
            }
            catch (Exception ex)
            {
                ExcelRecorder(0, "", ex.Message, row);
            }
            finally
            {
                System.GC.Collect();
            }
        }

I thought that the first catch block was enough to catch all the possible exceptions that can occur in my code. But I notice that, at times, the first catch block is not catching some general exceptions. That is why I added second catch block. Why is it happening? Why can’t my first catch block cover all exceptions?

  • 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-11T23:27:12+00:00Added an answer on June 11, 2026 at 11:27 pm

    The Exception class System.ServiceModel.FaultException can only handle contractually specified Faults

    You should be having a statement similar to the one below in your code

    throw new FaultException<DefaultFaultContract>(<parmaters>);
    

    which is causing the exception to be handled by the first catch block.
    When you don’t have a operation fault contractually specified,it will be handled by the generic Exception class(second catch block),from which all exception types derive.

    Please do check for the code samples given on this page.
    http://msdn.microsoft.com/en-us/library/ms576199.aspx

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

Sidebar

Related Questions

I am creating a findSpellings function that has two parameters $word and $allWords. $allwords
Having php code: function getChildren($parent_id = 0) { .... return $SomeChildrenArray; } And Smarty
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
Having trouble with each function... Will try to explain by example... In my code,
I' having a problem allocating a structure in a function. Here is the code(I'm
Just wondering, having the following simple code: var object1 = { name: function (){
I'm often having code written as follows try: self.title = item.title().content.string except AttributeError, e:
I'm currently porting a heap of code that has previously only been compiled with
I've been trying to write some very fast Java code that has to do
I'm having trouble adding proper exception handling to existing code that makes heavy use

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.