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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:28:49+00:00 2026-05-18T02:28:49+00:00

In our app, we use components developed by other teams. The question was how

  • 0

In our app, we use components developed by other teams. The question was how can I define a nicely way of exception handling than this

   try
   {
    someComponent.DoStuff();
   }

   catch (Exception ex)
   {
    textLabel= ex.Message;
   }

The component has no custom exception type, maybe a nicely way to do it would be to define a component specific Exception type and wrap this somehow?
I know the question is very basic, but I am interested more in the let’s say how it is good to do it. If you call another component with no custom defined exception types, how do you handle any potential exceptions in an elegant way?

  • 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-18T02:28:50+00:00Added an answer on May 18, 2026 at 2:28 am

    When you catch an error you are able to repackage it and then throw another error, at the most basic level you may just be adding more data – but, from what you’ve suggested, you could also replace the generic error with a custom error that, whilst it won’t overcome the limitations of the response you’ve got from the component, would give the code further up the call stack the opportunity to respond more appropriately.

    So in terms of just adding information in the most basic manner – by throwing a new exception with some additional text whilst still passing the original exception:

    catch (Exception ex)
    {
        throw new Exception("This is more about where the exception occurred", ex);
    }
    

    Now, if you want to define your own custom component exception you change the new Exception to new ComponentSpecificException adding data as necessary to the constructor but never forgetting to set the inner exception. Exceptions also have a data collection of key, value pairs into which you can insert more information (by creating the exception, adding the data and then doing the throw).

    That’s all fairly generic – working forward from there, where you can’t necessarily anticipate all the exceptions you have to handle you don’t try – you set up logging so that you know when you’ve got a generic exception i.e. one that hits the final catch – and then over time add exception specific catches above the generic to provide more appropriate responses or, at the very least, package up the error into less general custom exceptions.

    Not sure I’ve explained that very well – but the notion is that as its difficult to anticipate every possible error you want to have a strategy to develop your application in a systematic fashion as you discover new exceptions.

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

Sidebar

Related Questions

In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server
I want to use modal pop-up windows in our web app in Ruby on
I'm refurbishing a simple web-app that our field techs use. One of my goals
We have a 12-year-old Ms Access app that we use for our core inventory
I want to use Powershell to write some utilities, leveraging our own .NET components
Our website lets users create small widgets that can be embedded on other third
I use a WebView to display some internet content on one of our app's
On a page in our web app we use SyntaxHighlighter to highlight source code.
Would that be a reason for rejection of our app, if we use the
Our app (already deployed) is using an Access/Jet database. The upcoming version of our

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.