从catch块获取回溯 [英] Getting the backtrace from the catch block
本文介绍了从catch块获取回溯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 backtrace 来获取信息其中抛出异常。在我的异常的构造函数中,我将回溯存储在std :: string中,并且在catch块中为这种类型的异常打印此回溯。
I am using backtrace to get the information from where the exception is thrown. In the constructor of my exception, I am storing the backtrace in a std::string, and in the catch block for exceptions of this type, I am printing this backtrace.
但是我想知道,是否可能在catch块中为其他异常类型以某种方式获得相同的backtrace?
But I was wondering, is it possible to somehow get the same backtrace in the catch block for other exception types?
推荐答案
不这么认为。当执行者在catch块中停止时,堆栈被解开,之前发生的所有事情都不在堆栈中。
I don't think so. When executons stops in catch block the stack is unwound, and all that has happened before is not in stack anymore.
这篇关于从catch块获取回溯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文