Short version: What is "an exception as described in the C++ standard, 17.6.4.10 [res.on.exception.handling]" and how do I catch one?
Long version...
I would like to catch the exceptions thrown from the version of boost::create_directories() that does not take a system::error_code as an argument. The Boost Filesystem Error Reporting Documentation says that create_directories() reports errors either by...
a> throwing a boost::filesystem_error when a call by the implementation to an operating system or other underlying API results in an error that prevents the function from meeting its specifications, or...
b> throwing an exception as described in the C++ standard, 17.6.4.10 [res.on.exception.handling] when there is a failure to allocate storage.
The first case is obvious and I have handled that situation. But I can't find any explanation of how to handle the second case. Googling "exception as described in the C++ standard, 17.6.4.10 res.on.exception.handling" yields three articles (that could be a record for a non-zero search result), and none of them tell me how to handle such an exception.
Can anyone help?
I think what they mean is that they will (indirectly) throw std::bad_alloc. You may not actually want to try to catch that though, as a program which has run out of memory may not be able to continue in any case. Up to you though--I read this same documentation just the other day and that's the conclusion I came to.
The actual paragraph of the current C++11 standard regarding exception handling is §17.6.5.12. But there is no helpful information on what a boos library may throw except if the have throw specifying paragraphs.
I think what you want is to catch a std::exception since the most likely case in terms of " throwing an exception [...] when there is a failure to allocate storage" is a std::bad_alloc which derives from std::exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With