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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:52:29+00:00 2026-05-11T16:52:29+00:00

Recently I took a test at brainbench and got not a bad result (something

  • 0

Recently I took a test at brainbench and got not a bad result (something like 4.5, master degree). I didn’t know the answer only on 1 question (the rest I was sure about or at least I thought I knew the correct answer 🙂 ). The question is:

Which one of the following is NOT a reason to create custom exceptions?

Choice 1
To insert a strong label for later inspection
Choice 2
To strongly-type the purpose of a particular exception
Choice 3
To allow for remote serialization
Choice 4
To process common steps when an exception is created
Choice 5
To add custom properties for custom data propagation

I answered “4” – To process common steps when an exception is created. Which one you think is correct?

  • 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-11T16:52:29+00:00Added an answer on May 11, 2026 at 4:52 pm

    Choice 3. The base exception either already supports remoting, or else you deriving from it won’t add remoting.


    The “exception” Marc mentions in a comment is as follows; I think it’s not what the test writers had in mind:

    In a WCF service, you can allow an unhandled exception to propagate out of the service. WCF will turn it into a SOAP Fault, which may or may not contain details of the unhandled exception, depending on configuration.

    Better, would be to recognize certain sets of exceptions and translate them deliberately into SOAP Faults. For instance, a service that operates on database entities could expect that sometimes an entity would not be found; sometimes an attempt to add a new entity would result in a duplicate; sometimes an update attempt would have resulted in an invalid state. Such a service might decide to expose a NotFoundFault, DuplicateItemFault, and InvalidStateFault.

    The service would define the three faults as Data Contracts to define their contents:

    [DataContract]
    public class FaultBase {
        [DataMember]
        public string ErrorMessage {get;set;}
    }
    
    [DataContract]
    public class NotFoundFault : FaultBase {
        [DataMember]
        public int EntityId {get;set;}
    }
    
    [DataContract]
    public class DuplicateItemFault : FaultBase {
        [DataMember]
        public int EntityId {get;set}
    }
    
    [DataContract]
    public class InvalidStateFault : FaultBase {
    }
    

    You would then indicate that particular operations can return such faults:

    [OperationContract]
    [FaultContract(typeof(NotFoundFault))]
    public Entity GetEntityById(int id)
    

    Finally, you might wrap an exception from the DAL in such a way that WCF will return the particular fault instead:

        try {
            return DAL.GetEntity<Entity>(id);
        }
        catch (DAL.NoSuchEntityException ex)
        {
            throw new FaultException<NotFoundFault>(
                new NotFoundFault {EntityId = ex.Id, ErrorMessage = "Can't find entity"});
        }
    

    I think the test developer was trying to get you to think that something special needs to be done in order for an exception to be serialized for remoting to a different AppDomain. This will not be the case if the custom exception was properly implemented, as the supplied .NET exception classes are all serializable. Thus, the ability to serialize is not an excuse to create a custom exception, as the base class should already be serializable.

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

Sidebar

Related Questions

I recently took an objective-c test to see how I would do. Turns out
I recently took my Db initiating code out of the __construct of my Page
Recently we got a new server at the office purely for testing purposes. It
I recently took a class at school where we had to learn Scheme to
I recently took in a small MCF C++ application, which is obviously in a
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently our site has been deluged with the resurgence of the Asprox botnet SQL

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.