#include <iostream>
#include <exception>
void terminate_handler() {
std::cout << "Custom terminate handler called" << std::endl;
std::abort();
}
void throw_unexpected() noexcept(false) {
throw std::runtime_error("Unexpected exception");
}
int main() {
std::set_terminate(terminate_handler);
try {
throw_unexpected();
} catch (const std::runtime_error& e) {
std::cout << "Caught runtime_error exception: " << e.what() << std::endl;
} catch (...) {
std::cout << "Caught unknown exception" << std::endl;
}
return 0;
}