#include <iostream>
#include <stdexcept>
using namespace std;
void methodWithException() {
try {
throw runtime_error("test exception");
}
catch (exception & e) {
//实现任意部分处理,
//并把错误传给调用方代码
throw;
}
}
try {
methodWithException();
}
catch (runtime_error & e) {
cout << e.what();
}