
David Abrahams wrote:
std::runtime_error loses meaning pretty quickly when you look at it closely, since everything reported by an exception is a runtime error, by definition :)
IIUC though, there remains a distinction between std::runtime_error and std::logic_error. The former is intended to report exceptional conditions that cannot be detected until runtime, such as losing a network connection halfway through a read. The latter is for conditions that can (potentially) be avoided by better coding, such as failing consistency checks and dividing by zero, where the violating arguments can be detected and re-routed up front. Ultimately, we (typically) throw a runtime_error after performing a check on some return value at run-time, so you could argue that program logic can handle recovery here too. I guess it is the difference between signalling 'help! stuff happened' and 'you shouldn't have done that!' System API failures are generally external to the component/library author's control, and fall into the 'stuff happened' category. -- AlisdairM