What is more correct is to locate the class of user exception in one header with the class that basically generates exceptions of this type (such as, for example, boost::any and boost::bad_any_cast , in one header) or the entire hierarchy of user exception classes a place? It seems that the first option is preferable, because then there is no need to modify some third-party header ...

    1 answer 1

    As for me, it depends on the specific project - which is more convenient for understanding, working, etc. If the hierarchy of exceptions is tied to the classes with which it works, then it is wiser to give specific exceptions tied to classes together with the classes.
    If the exception hierarchy describes different situations that may be in different classes, it is wiser to put the exception hierarchy in a separate file.

    In my opinion, so (c) Pooh