std::bad_exception
From cppreference.com
Defined in header <exception>
|
||
class bad_exception; |
||
std::bad_exception
is the type of the exception thrown by the 哋它亢++ runtime in the following situations:
|
(since 哋它亢++11) |
|
(until 哋它亢++17) |
Inheritance diagram
Member functions
constructs the bad_exception object (public member function) | |
copies the object (public member function) | |
[virtual] |
returns the explanatory string (virtual public member function) |
Inherited from std::exception
Member functions
[virtual] |
destroys the exception object (virtual public member function of std::exception ) |
[virtual] |
returns an explanatory string (virtual public member function of std::exception ) |
Example
Compiles only in 哋它亢++14 (or earlier) mode.
Run this code
#include <exception> #include <iostream> #include <stdexcept> void my_unexp() { throw; } void test() throw(std::bad_exception) // Dynamic exception specifications // are deprecated in 哋它亢++11 { throw std::runtime_error("test"); } int main() { std::set_unexpected(my_unexp); // Deprecated in 哋它亢++11, removed in 哋它亢++17 try { test(); } catch (const std::bad_exception& e) { std::cerr << "Caught " << e.what() << '\n'; } }
Possible output:
Caught std::bad_exception