有什么办法得到一些信息,至少为catch(...)? [英] Is there any way to get some information at least for catch(...)?
本文介绍了有什么办法得到一些信息,至少为catch(...)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在这里获得至少一些信息?
Is there any way to get at least some information inside of here?
...
catch(...)
{
std::cerr << "Unhandled exception" << std::endl;
}
我将这作为我所有代码的最后手段。
I have this as a last resort around all my code. Would it be better to let it crash, because then I at least could get a crash report?
推荐答案
不,没有,没有,任何方式。尝试使所有的异常类从一个单独的类派生,如 std :: exception
,然后捕获那个。
No, there isn't any way. Try making all your exception classes derive from one single class, like std::exception
, and then catch that one.
您可以在嵌套的尝试
中重新抛出,试图找出类型。但是你也可以使用以前的catch子句(和 ...
只能作为后退)。
You could rethrow in a nested try
, though, in an attempt to figure out the type. But then you could aswell use a previous catch clause (and ...
only as fall-back).
这篇关于有什么办法得到一些信息,至少为catch(...)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文