4 ms·
This is not an accurate summary of what C++ exceptions where "meant for". Here's Bjarne in 1989: "The author of a library can detect errors, but does not in ge
by PaulDavisThe1st 7y ago
This is not an accurate summary of what C++ exceptions where "meant for". Here's Bjarne in 1989:
"The author of a library can detect errors, but does not in general have any idea what to do about them. The user of a library may know how to cope with such errors, but cannot detect them – or else they would have been handled in the user’s code and not left for the library to find.
The primary purpose of the exception handling mechanism described here is to cope with this problem for C++ programs; other uses of what has been called exception handling in the literature are considered secondary. See the references for discussions of exception handling techniques and mechanisms."
- edoo 7y agoI think it depends what you consider an error. For example let's say I have a library that opens sockets to hosts. If I can't reach the host that isn't an error and I report back a failure of that function to succeed. If I can't allocate the memory for a socket then instead of reporting a failure to connect I throw an exception for the true error.