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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:20:44+00:00 2026-05-23T08:20:44+00:00

I work on a legacy code in c++ which uses error codes instead of

  • 0

I work on a legacy code in c++ which uses error codes instead of exceptions.

In this case, fn A() calls B() which calls C() etc.

Now if C() returns the error, i would like to exit at B() itself without having to pass it back to A() and have A() handle the error. However few other team members have the top most function do the error handling. Now which one would be good?

Also in the latter case, since we dont exit early enough, there happens to be multiple return statements. No i have heard somewhere that multiple return in a function should be avoided. If i avoid return then there are nested ifs to deal with.

  • 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-23T08:20:45+00:00Added an answer on May 23, 2026 at 8:20 am

    I think that errors should be handled as locally as possible. That is, if a class’ method has enough knowledge to handle an error, it should do so. However, if the way to handle an error si to exit the program, I think this criterion doesn’t apply. In that case, you should return back in a phased manner, like @Als says, and have a single exit point. In other cases, handle the error as locally as possible.

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

Sidebar

Related Questions

I'm working with a legacy piece of code in some stuff for work which
At work, I am working with this old legacy code modified Cake-PHP code that
We are ready to start a brand new project at work, no legacy code.
I'm migrating a legacy codebase at work from python 2.4 to python 2.6. This
I have the following code from a legacy app which currently reads from an
We are a team working on legacy code which is pretty old and written
Attempting to generics-ify some legacy code, I'm stuck. I have a ParentObject which wraps
I have a lot of legacy code which I currently compile using an antiquated
For reasons which are somewhat unavoidable (lots of legacy code, compatibility, design needs) I
In my project, legacy code generates xml which has following structure : <Output> <Template

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.