Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the disadvantages of having one base class for all exceptions?

Tags:

People also ask

What is base class for all types of exceptions?

SystemException class is the base class for all predefined system exception.

What are the disadvantages of exception handling in C++?

Exception handlers have disadvantages. If a function does not return because it, or some other function it called, threw an exception, data might be left in an inconsistent state. You need to know when an exception might be thrown, and whether the exception might have a bad effect on the program state.

What is the base class for all exceptions in Python?

The BaseException is the base class of all other exceptions. User defined classes cannot be directly derived from this class, to derive user defied class, we need to use Exception class.

Is the base class of exception?

All exception and error types are subclasses of class Throwable, which is the base class of the hierarchy.


I'm doing the exercises from Stroustrup's C++ Programming Language 4th Edition. One of the tasks is formulated like this:

Consider using a class Exception as the base of all classes used as exceptions. What should it look like? How should it be used? What good might it do? What disadvantages might result from a requirement to use such a class?

The answer looks pretty much like std::exception, save for the disadvantages part - the only one I can imagine is the cost of __vptr which is usually considered negligible. What am I missing here?