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

  • Home
  • SEARCH
  • 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 6887939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:56:48+00:00 2026-05-27T05:56:48+00:00

I have read several times that using catch (Exception ex) { Logger.LogError(ex); } without

  • 0

I have read several times that using

catch (Exception ex) 
{
    Logger.LogError(ex);
}

without re throwing is wrong, because you may be hiding exceptions that you don’t know about from the rest of the code.

However, I am writing a WCF service and am finding myself doing this in several places in order to ensure that the service does not crash. (SOA states that clients should not know or care about internal service errors since they unaware of the service implementation)

For instance, my service reads data from the file system. Since the file system is unpredictable I am trapping all exceptions from the read code. This might be due to bad data, permission problems, missing files etc etc. The client doesn’t care, it just gets a “Data not available” response and the real reason is logged in the service log. I don’t care either, I just know there was a problem reading and I don’t want to crash.

Now I can understand there may be exceptions thrown unrelated to the file system. eg. maybe I’m out of memory and trying to create a read buffer has thrown an exception. The fact remains however, that the memory problem is still related to the read. I tried to read and was unable to. Maybe there is still enough memory around for the rest of the service to run. Do I rethrow the memory exception and crash the service even though it won’t cause a problem for anything else?

I do appreciate the general idea of only catching exceptions you can deal with, but surely if you have an independent piece of code that can fail without affecting anything else, then it’s ok to trap any errors generated by that code? Surely it’s no different from having an app wide exception handler?

EDIT: To clarify, the catch is not empty, the exception is logged. Bad example code by me, sorry. Have changed now.

  • 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-27T05:56:49+00:00Added an answer on May 27, 2026 at 5:56 am

    I wouldn’t say that your service works as expected if there are permission problems on the disk. imho a service returning "Data not available" is even worse than a service returning “Error”.

    imagine that you are the user of your service. You make a call to it and it returns “No data”. You know that you’re call is correct, but since you don’t get any data you’ll assume that the problem is yours and go back investigating. Lots of hours can be spent in this way.

    Which is better? Treating the error as an error, or lie to your users?

    Update

    What the error depends on doesn’t really matter. Access problems should be dealt with. A disk that fails sometimes should be mirrored etc etc. SOA puts more responsibilities on you as a developer. Hiding errors doesn’t make them go away.

    SOA should pass errors. It may not be a detailed error, but it should be enough for the client to understand that the server had a problem. Based on that, the client may try again later on, or just log the error or inform the service desk that a manual action might need to be taken.

    If you return “No data”, you won’t give your users a chance to treat the error as they see fit.

    Update2

    I do use catch all in my top level. I log exceptions to the event log (which is being monitored).

    Your original question didn’t have anything in the catch (which it do now). It’s fine as long as you remember to monitor that log (so that you can correct those errors).

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

Sidebar

Related Questions

I have read in several places that it's possible to share the objects directory
I'm quite confused about several books in .NET that I have read. Would someone
I have read that using database keys in a URL is a bad thing
I have several database access methods that are wrapped in a try/catch block: function
I have read several documentations about building custom ErrorHandler (by inheriting from IErrorHandler). Unfortunately,
I have read several post on both matters but I haven't seen anyone comparing
I have read through several reviews on Amazon and some books seem outdated. I
I have read a lot that LISP can redefine syntax on the fly, presumably
I have read on Stack Overflow some people that have converting to C#2.0 to
My application communicates with several GSM electric controllers, that means that I have to

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.