Is it useful to throw different exceptions for instance std::runtime_error or std::invalid_argument in huge projects? Or is it better to throw in general std::exception with a good text parameter for what()? And when does it make sence to derive some sub classes from std::exception?
Rumo
It always makes sense to use throw the most specific exception. As each exception should be derived from
std::exceptionthe code catching may decide at which level of granularity it wants to handle it (catch by reference! Item 13 in “More effective C++” from S. Meyers).Using only
std::exceptionwith only some text a no-go:what()provides an adequate text for any exception if you need.