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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:29:41+00:00 2026-05-29T04:29:41+00:00

What is the better approach when handling errors – throwing it as an exception

  • 0

What is the better approach when handling errors – throwing it as an exception or returning a an object that contains the error and its details?

I’m thinking what is the better approach to notifying errors – in terms of system resources, coding practices and overall enterprise practices ?

I’ve seen in most cases, the sample code throws a custom exception containing the error information. But I was thinking if it was better to just return an object instantiated from a class (for example: class DatabaseError)?

I believe throwing exceptions in C# can be resource intensive and this would involve having (possibly) a lot of try-catch blocks.

Thanks!

  • 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-29T04:29:42+00:00Added an answer on May 29, 2026 at 4:29 am

    Exceptions are generally considered to be the preferred mechanism for relaying error conditions up the application chain to where they can be dealt with and managed in such a way that they do not cause the application to fail completely and terminate.

    However, it is also generally considered poor practice to use the exception-handling mechanism as a logic path – that is, to make the catching of an error condition a prerequisite for later correct or alternative functionality (e.g. to attempt to open a file which may or may not exist, catch the exception if it does not exist, and present a file-browser dialog as a consequence – in this example, the ‘NOT FOUND’ error condition should be detected before attempting to open the file rather than regarding the exception path as the route by which the user is asked to locate it).

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

Sidebar

Related Questions

Which is a better approach to exception handling and why?: (1) Defining a single
What do you consider best practice when it comes to error handling errors in
What would be a better approach to compare two floating point values - using
What is a better approach to serialize custom class: using XMLSerializer or BinarryFormatter and
I'd like to know if there's a better approach to this problem. I want
Can Any one suggest me which is the better approach to work with NSInputStream.
When coding, what in your experience is a better approach? Break the problem down
Nested If or single if with And operator, which is better approach? Single If
Which approach is better: 1) to use a third-party ORM system or 2) manually
Which approach is better to use if I need a member (sp or func)

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.