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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:34:09+00:00 2026-05-16T18:34:09+00:00

this might sound like a daft question but I can’t seem to find a

  • 0

this might sound like a daft question but I can’t seem to find a obvious answer. I have to quickly create a simple WCF service and I have created all the classes I need decorated with the DataContract and DataMember attributes and I have created a custom exception class and everything is working. However if an exception is thrown within my service no matter what it is should I always throw my FaultException<MyException> with a detailed message or use different exception types. I’m guessing I always throw that exception as the client can handle that single exception type.

Also if the client passes me a completely null object then I realise that is normal to throw an exception but what if a member of that class is not as expected such as null or even an empty string? Would I still throw my exception with that as the reason or would I just return a message in my response object? I know this might sound like a stupid question but just concerned that I might use exceptions to drive the functionality but then I’m thinking that throwing an exeption makes sense.

Many Thanks

Paul

  • 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-16T18:34:10+00:00Added an answer on May 16, 2026 at 6:34 pm

    WCF supports “two types” of exceptions. First is unexpected exception – every common .NET exception thrown from your code, every unhandled exception and every non generic FaultException is handled as unexpected exception. Unexpected exception is SOAP:Fault which is not described in WSDL. Unexpected exception faults the channel.

    Second type are expected exceptions. Expected exceptions are defined as FaultContracts. You throw expected exception by trhowing generic FaultException. Expected exceptions are described in WSDL as wsdl:fault messages for operations. Fault contract is added as XSD type for expected exception. Because of this client can parse Detail of SOAP:Fault and provide it as strongly typed object. You can provide some information about exception in fault contract – it is just on you what information do you provide to a client.

    When you code your service you have to differ what is expected exception and what is not. For example when you create operation GetDataById expected exception is DataNotFound or IncorrectIdFormat, etc. So data validation is expected exception and you can say your user what field had incorrect value. You can also have some general expected exception to wrap other unexpected problems – this exception should be usually used in IErrorHandler implementation as global exception handler. If you don’t use global exception handler you should not deal with unexpected exceptions.

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

Sidebar

Related Questions

This might sound like an obvious question but I can't seem to find the
This might sound like a reaaaally dumb question but... why do browsers have a
This might sound like a noob question, but here it goes anyway. Can BlackBerry
This might sound like an obvious question, but I'm new to CouchDB, so I
I know this might sound like a dumb question, but I have looked every
This might sound like a little bit of a crazy question, but how can
This might sound like an odd question but how can on define a generic
This might sound like a strange question, but bear with me... I have a
This might sound like a silly question, but I couldn't find information on how
This might sound like a stupid question but just trying to learn something here.

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.