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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:47:48+00:00 2026-05-24T15:47:48+00:00

I tried to make an exception class (lets call it EXP) that will be

  • 0

I tried to make an exception class (lets call it EXP) that will be able to catch various types of other exception classes (for instance, std::exception), but without any success.
The main problem is that there are many types of exceptions that I need to catch, and I wondered if there is a better way than writing a macro that holds all the possible catches.

What I want to do (if its even possible) is something like that:

class EXP : ?? maybe must inherit ??
{
    // EXP implementation
}

EXP is defined in such a way that this is possible:

try
{
   throw std::exception("error string");
}
catch(const EXP& e)
{
   // catches the exception
}

So if it is possible, how can I define EXP so it will do what I want?

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-24T15:47:49+00:00Added an answer on May 24, 2026 at 3:47 pm
    • first, it is generally a terrible idea to catch every exception type. Generally speaking, if you don’t know what the exception is, how can you meaningfully handle when it occurs?
    • second, if you want to catch every exception type, you can use catch (...). However, this does not directly give you access to the caught exception object. To access the exception object you then have to rethrow and catch each specific type that you’re supporting (this rethrowing and recatching can be done in a separate function, which may be a solution to your question).
    • third, even this only catches C++ exceptions. Other errors, such as segmentation faults/access violations won’t be caught by this. If you want to catch that kind of errors, you’ll need to use platform-specific operations or language extensions.
    • finally, type conversions aren’t considered when catching exceptions. If an exception type E is thrown, then you can only handle it by catching E or any of its base classes. But you can’t, for example, handle it by catching an exception that is constructible from an E.

    Note: regarding the rethrowing scheme in the second point, it may not work with pre-standard compilers; e.g. it does not work with Visual C++ 6.0.

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

Sidebar

Related Questions

I tried to make the title as clear as possible... here is my scenario:
While creating a file synchronization program in C# I tried to make a method
I am tying to make comments in a blog engine XSS-safe. Tried a lot
I've tried scrolling=no and overflow:hidden; Nothing seems to make the vertical scrollbar go away
I am writing a simple Interface class as below. I need to make only
I am trying to make my first Android app. I noticed that the SQLiteOpenHelper.onCreate()
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo
Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
I tried to install Delphi 7 on Vista several times and Vista prevented me
I tried scouring the web for help on this issue, but there are so

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.