#include <iostream>
#include <exception>
#include <stdexcept>

void universal_exception_handler(std::exception_ptr e)
{
	try
	{
		std::rethrow_exception(e);
	}
	catch (const std::logic_error& e)
	{
		std::cout << "logic_error" << std::endl;
	}
	catch (const std::runtime_error& e)
	{
		std::cout << "runtime_error" << std::endl;
	}
}

void foo()
{
	throw std::logic_error{""};
}

void bar()
{
	throw std::runtime_error{""};
}

int main()
{
	try
	{
		foo();
	}
	catch (...)
	{
		universal_exception_handler(std::current_exception());
	}
	
	try
	{
		bar();
	}
	catch (...)
	{
		universal_exception_handler(std::current_exception());
	}
}
