try { foo(); catch (std::exception &e) { handle_exception (); } int foo () { int rc = fx (); if (rc != 0) throw std::exception ("Error!"); }