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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:36:51+00:00 2026-05-11T00:36:51+00:00

How should exceptions be dispatched so that error handling and diagnostics can be handled

  • 0

How should exceptions be dispatched so that error handling and diagnostics can be handled in a centralized, user-friendly manner?

For example:

  • A DataHW class handles communication with some data acquisition hardware.
  • The DataHW class may throw exceptions based on a number of possible errors: intermittent signal, no signal, CRC failure, driver error. Each type of error gets its own exception class.
  • The DataHW class is called by a number of different pieces of code that do different types of acquisition and analysis.

The proper error handling strategy depends on the type of exception and the operation being attempted. (On intermittent signal, retry X times then tell the user; on a driver error, log an error and restart the driver; etc.) How should this error handling strategy be invoked?

  • Coding error recovery into each exception class: This would result in exception classes that are rather large and contain high-level UI and system management code. This seems bad.
  • Providing a separate catch block for each type of exception: Since the DataHW class is called from many different places, each catch block would have to be duplicated at each call site. This seems bad.
  • Using a single catch block that calls some ExceptionDispatch function with a giant RTTI-based switch statement: RTTI and switch usually indicates a failure to apply OO design, but this seems the least bad alternative.
  • 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. 2026-05-11T00:36:52+00:00Added an answer on May 11, 2026 at 12:36 am

    Avoid duplicating the catch blocks at each call site by catching (…) and calling a shared handler function which rethrows and dispatches:

    f() {     try     {         // something     }     catch (...)     {         handle();     } }  void handle() {     try     {         throw;     }     catch (const Foo& e)     {         // handle Foo     }     catch (const Bar& e)     {         // handle Bar     }     // etc } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer In more recent versions of SQL Server you can use… May 11, 2026 at 12:01 pm
  • added an answer What about: if (s.Length > 1) { uiText = string.Format('{0}… May 11, 2026 at 12:01 pm
  • added an answer If you don't want to modify code, you can also… May 11, 2026 at 12:01 pm

Related Questions

How should exceptions be dispatched so that error handling and diagnostics can be handled
How should widgets in GWT inform other widgets to refresh themselfs or perform some
How should I run another program from within my C program? I need to
How should I store (and present) the text on a website intended for worldwide
How should I determine what to use for a listening socket's backlog parameter? Is
How should I check if my ISP blocks port 25?
How should I initiate a delete action from my view? Creating a new form-tag
How should I perform garbage collection in a program that consists of multiple threads
How should I use the unit of work pattern in the following scenario: I'm
How should I check a (TCP) socket to find out whether it is connected?

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.