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

My WCF service exposes this function public SerialNumberInfo GetSerialNumberInfo(string serialNumber) { } Is there
I have a WCF service hosted on IIS and it accepts connection like this
WCF service has one method ( Let's say TestMethod) in which I try to
This WCF Service returns a TIFF image. It checks if it is connected to
I tried to catch all exception of wcf sercue with/without SSL/TLS or endpoint, something
I have a WCF service that has webHttpBinding and has enableWebScript turned on in
my WCF service get request looks like below: ../myservice.svc/search?q=keywords&op=xml ../myservice.svc/search?q=keywords&op=json so based on param
I have a WCF service Operation, I'd like it to return an object graph
A WCF service named Portal.WebServices.TaskListService uses a codebehind file TaskListService.svc.cs . In this file
WCF Service INTERFACE : [ServiceContract] public interface ITest { [OperationContract] int TestCall(GenericType<MyType> x); [OperationContract]

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.