Dovrebbe bastare inserire un
catch (...)
per acchiappare ogni tipo di eccezione. Ovviamente non si può sapere quale.
Puoi mettere anche più catch in cascata nel main.
Codice PHP:
try {
...
} catch (std::out_of_range& err) {
...
} catch (std::bad_alloc& err) {
...
} catch (std::runtime_error& err) {
...
} catch (...) {
}