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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:40:39+00:00 2026-05-13T08:40:39+00:00

When the WCF service is turned off, I’m gonna catch this exception like this.

  • 0

When the WCF service is turned off, I’m gonna catch this exception like this.

   public List<ProjektyEntity> GetProjekty()
   {
      try
      {
         return this.channel.GetProjekty();
       }
       catch (EndpointNotFoundException exception)
       {
          //what to do at this point ?
       }
    }

But i don’t know what to do in the catch block.I can return only an object of type List<ProjektyEntity> I’d like to write a message to the user,something like “The service is turned off” My presentation layer is ASP.NET MVC. Is there any strategy for this kind of situations?

  • 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-13T08:40:40+00:00Added an answer on May 13, 2026 at 8:40 am

    There’s a simple rule: If you don’t know how to handle an exception, don’t catch it.

    Catching it and retuning null or an empty list would be about the worst thing you can do because it will be hard to debug where the error is coming from, or even that an error occured at all. If you do this you will have developers pulling their hair out.

    Catching an exception and rethrowing it as throw e; is also bad because you lose the original stack. Rethrowing using throw; is OK sometimes if you have special clean up you need to do only if there is an error. Usually this is not the case. If you have cleanup that should be done whether or not there was an error, it belongs in the finally clause.

    So in general unless there is something sensible you can do to recover from the error, just let the exception propogate to the caller. This is how exceptions are designed to work.

    There are a few times when you might want to catch an exception to add more information (e.g. for logging), in which case you should ensure that you use an InnerException to avoid losing the original information:

    try
    {
        foo(bar);
    }
    catch (Exception e)
    {
        throw new FooException("Foo failed for " + bar.ToString(), e);
    }
    

    but in general it’s best not to do this unless you have a very good reason. Doing this prevents your users from catching a specific type of exception – they will catch your exception and then they need to switch on the type of the InnerException. Not fun. Just let the caller see the original exception.

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

Sidebar

Related Questions

I've got a WCF service which handles some sensitive data. I'd like to make
My WCF Service uses wsHttpBinding and works fine from the client when the service
My WCF service involves the sending of a dataset (in csv format) data between
A WCF service exposing multiple elements in DataContract as DataMember [DataMember(IsRequired = true, EmitDefaultValue
I've created a WCF service and when I browse to the endpoint I get
I have a WCF service that I have to reference from a .net 2.0
Which of the WCF Service Protocols work well with Java? Do the TCP Service
I've build a WCF Service to accept a file and write it to disk.
I'm writing a WCF service for the first time. The service and all of
We have an existing WCF service that makes use of wsDualHttpBinding to enable callbacks

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.