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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:58:06+00:00 2026-05-14T08:58:06+00:00

Our code catches the general exception everywhere. Usually it writes the error to a

  • 0

Our code catches the general exception everywhere.

Usually it writes the error to a log table in the database and shows a MessageBox to the user to say that the operation requested failed. If there is database interaction, the transaction is rolled back.

I have introduced a business logic layer and a data access layer to unravel some of the logic. In the data access layer, I have chosen not to catch anything and I also throw ArgumentNullExceptions and ArgumentOutOfRangeExceptions so that the message passed up the stack does not come straight from the database.

In the business logic layer I put a try catch. In the catch I rollback the transaction, do
the logging and rethrow.

In the presentation layer there is another try catch that displays a MessageBox.

I am now thinking about catching a DataException and an ArgumentException instead of an Exception where I know the code only accesses a database.

Where the code accesses a web service, then I thought I would create my own “WebServiceException”, which would be created in the data access layer whenever an HttpException, WebException or SoapException is thrown.

So now, generally I will be catching 2 or 3 exceptions where currently I catch just the general Exception, and I think that seems OK to me. Does anyone wrap exceptions up again to carry the message up to the presentation layer?

I think I should probably add a try catch to Main() that catches Exception, attempts to log it, displays an “Application has encountered an error” message and exits the application.
So, my question is, does anyone see any holes in my plan? Are there any obvious exceptions that I should be catching or do these ones pretty much cover it (other than file access – I think there is only 1 place where we read-write to a config file).

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

    I would use try/finally (or the using statement which is equivalent) for your rollback, rather than doing it in a catch block. In particular if you are only catching specific exceptions, you will still want the database rollback to take place if an unexpected Exception type is thrown.

    With few exceptions I rarely use a catch anywhere except:

    • At a physical tier boundary I use try/catch with log/throw in the catch block so that exceptions can be logged on the server. With newer technologies such as WCF exceptions can be logged without a try/catch (e.g. with a WCF DispatchBehavior).

    • In a top-level handler in the presentation tier.

    In the business and data tiers, there will be a lot of try/finally (i.e. using statements) but almost never a catch.

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

Sidebar

Ask A Question

Stats

  • Questions 389k
  • Answers 389k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, but you will need to do some work (see… May 15, 2026 at 12:53 am
  • Editorial Team
    Editorial Team added an answer Your problem is that the i variable is shared by… May 15, 2026 at 12:53 am
  • Editorial Team
    Editorial Team added an answer With your acknowledgement that this is more about coding consistency… May 15, 2026 at 12:53 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.