Mer*_*rad 1 c++ exception-handling exception
我有一段时间没有做过C++而且我的记忆很模糊,到目前为止我找不到确定的答案.我不是在讨论重新抛出捕获的异常,而是捕获一个异常并抛出不同的类型,例如:
std::unordered_map<int, int> foo;
...
int getFoo(int id)
{
try {
return foo.at(id);
}
catch (std::out_of_range& e)
{
throw MyMoreDescriptiveExceptionType();
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
282 次 |
最近记录: |