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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:26+00:00 2026-05-26T12:38:26+00:00

I have asked a few questions on here and read a few articles around

  • 0

I have asked a few questions on here and read a few articles around exception handling but don’t think I’m really grasping when you should and when you shouldn’t handle an exception. From the articles I’ve read it states to “only handle exceptions you can recover from” What does it mean by that. If I can’t handle the exception what do I do? Let it propagate back up the stack? If I don’t handle it how can I log it and present a user friendly error message. What do most people do in web apps and web services?

As an example say I have a lower tier data layer that pulls data from sql

try{
  //do something with db
}catch(SqlException ex){
 //what should i do here
 //should i call code again to retry getting data from db
}catch(Exception ex){
 //should i even catch exception of type exception
}

How do I handle exceptions in lower tiers? Should I just let the exception bubble up the tiers? If so then if I want to catch an exception of type sqlexception then I need a reference to the library sqlexception is part of but surely I shouldn’t have to reference that library in a layer that has nothing to do with data access.

  • 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-26T12:38:26+00:00Added an answer on May 26, 2026 at 12:38 pm

    Exception management is a large subject, so I’ll only touch the surface here.

    From the articles ive read it states to “only handle exceptions you can recover from” What does it mean by that.

    If you don’t know how to recover from a specific exception, then there’s not usually any point in catching it. If it’s a web app or service, the web server itself will deal with the logging and recovery.

    In some cases, you need to catch exceptions so that you can a generic recovery, for example by cancelling or reversing a transaction. In that case, an acceptable approach is to
    catch the exception, do the generic recovery, and then throw the exception again.

    If i cant handle the exception what do i do. Let it propgate back up the stack?

    Yes.

    If i dont handle it how can i log it and present a user friendly error message. What do most people do in web apps and web services?

    The web server will log the exception. If you want to present a user-friendly error message in a web app, you can catch/log at the highest level of the stack and re-direct to your error message. Again, I would try not to catch System.Exception – instead make a list of the exceptions that your app throws, and catch just these types before presenting a message tailored to each type. As the list of exception types grows, either prevent each new exception type by changing the code, or add a new catch for that exception type.

    In a web service, you can create a custom exception and add that as a node to the generic exception that the web service will provide.

    In your code example, I wouldn’t use try…catch unless you’re expecting an exception and you know what to do with it.

    How do i handle exceptions in lower tiers. Should i just let the exception bubble up the tiers.

    Yes.

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

Sidebar

Related Questions

I've asked a few questions which have touched around this issue, but I've been
I know this question has been asked here before, but I don't think those
I know this questions has been asked a few times here. But these seem
There have been a few questions asked here about why you can't define static
I know similar questions have been asked before but i think this is slightly
I have seen this question asked here a few times, but most question didn't
Guys I've asked few days ago a question and didn't have really time to
Ok, I've asked a few related questions here and only ended up with more
I see that there have been similar questions asked here regarding wrapping unmanaged C++
I've asked here a ton of questions about WSAAsyncSelect and NET.Few months ago I

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.