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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:37:41+00:00 2026-06-02T19:37:41+00:00

In my project codding i have to use a try catch method to find

  • 0

In my project codding i have to use a try catch method to find the function execution status.

   try
   {
      //sample code
      //calling functions
      function1();
      function2();
      //........
   }
   catch(//need to catch exception)
   { 
    return failure;
   }

My requirement is that i have to catch all the exceptions that thrown from the try block

i have two options here,

  1. catch(…)
  2. catch(std::exception)

I think the first one will catch all the exceptions. And the second one, std::exception is the base class for all other exception classes in my program

   class MyException : public std::exception
   {
    // All the exceptions that i have use is derived from this class
   }. 

Which is better and more efficient.

Is the both method works same way. Help me and suggest any method

  • 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-06-02T19:37:42+00:00Added an answer on June 2, 2026 at 7:37 pm

    Always keep your specification as focused as possible so that you catch those that you know could be thrown, and catch derived exceptions (more specialised) before base ones:

    try
    {
        // Some stuff
    }
    catch (Derived& e)
    {
        // Deal with specifics of Derived
    }
    catch (Base& e) 
    {
        // Deal with general case of Base
    }
    

    Never use catch(...) except at the very top of your program stack (and certainly not in libraries.) When you do this, you cannot be sure about what caused the exception and therefore you cannot necessarily rely on things that you normaly would (such as memory management etc.)

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

Sidebar

Related Questions

Can someone suggest a sample project[Any task/project/coding activity] where I can use Java collections
i have to design a localhost application that one code at other project returns
I've been coding a very sizable project and I have run into trouble with
I have a database (sql 2008 mdf file), a class library project with an
I have several files with code testing code (which uses a unittest class). Later
I'd like to use CMake to run some tests for an xslt coding project.
I have a WPF application and I added to the project resources many icons
I have been working for several months on a RoR project with fellows university
I'm a .Net developer, but for my current project I have to create some
I have a project where I have to interact with two different devices that

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.