Error Handling in C++

Posted on 2006-05-06
Last Modified: 2010-04-01
What other ways are available for error handling in C++ besides throwiing an exception? Is one type better to use than the other? What kind of scenarios would they be used in?
Question by:Wookie68
    LVL 86

    Accepted Solution

    You basically have two choices - the one being exception, the other returning error codews from function calls. Both have their pros and cons, but I'd say it depends on the actual situation which weapon you choose. If you e.g. work with a library that makes use of throwing exeptions (just as e.g. STL), you better pick that concept, if you are only orking with an APIesque construct, return values are OK. Even a healthy mixture of both can have some real beauty.
    LVL 8

    Expert Comment

    You can always create wrapper that will turn error code into exception or exception into error code.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now