Defined in header <exception> | ||
---|---|---|
class bad_exception; |
std::bad_exception
is the type of the exception thrown by the C++ runtime in the following situations:
| (since C++11) |
| (until C++17) |
Inheritance diagram.
constructs the bad_exception object (public member function) |
|
copies the object (public member function) |
|
[virtual] | returns the explanatory string (virtual public member function) |
[virtual] | destroys the exception object (virtual public member function of std::exception ) |
[virtual] | returns an explanatory string (virtual public member function of std::exception ) |
#include <iostream> #include <exception> #include <stdexcept> void my_unexp() { throw; } void test() throw(std::bad_exception) { throw std::runtime_error("test"); } int main() { std::set_unexpected(my_unexp); try { test(); } catch(const std::bad_exception& e) { std::cerr << "Caught " << e.what() << '\n'; } }
Possible output:
Caught std::bad_exception
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/error/bad_exception