try { code } // only catches FutureValueError catch (FutureValueError& e) { handler1 } // catches all other logic_error catch (logic_error& e) { handler2 } catch (bad_alloc& e) { handler3 }