boost::exception-如何打印详细信息
boost::exception - how to print details?
我的程序中有这样的代码:
catch (boost::exception& ex) {
// error handling
}
如何打印详细信息?错误消息、堆栈跟踪等。?
对于像boost::exception
这样通用的东西,我认为您正在寻找boost::diagnostic_information
函数来获得更好的字符串表示。
#include <boost/exception/diagnostic_information.hpp>
catch (const boost::exception& ex) {
// error handling
std::string info = boost::diagnostic_information(ex);
log_exception(info); // some logging function you have
}
要获取异常的堆栈,我将从StackOverflow问题C++显示异常的堆栈跟踪开始。
您可以使用boost::diagnostic_information()来获取实际的错误消息和异常的来源。即
catch (const boost::exception& ex) {
// error handling
std::cerr << boost::diagnostic_information(ex);
}
相关文章:
- std::extent 实现详细信息说明
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- 如何使用软化工具包从 OPC UA 服务器异步读取操作回调中的数据值响应中获取 NodeId 详细信息
- protobuf,如何在protobuf消息中遍历所有集合字段,我不知道详细信息?(C++)
- AVX2收集指令使用详细信息
- 只知道运行时的数据类型.如何将数据详细信息隐藏到使用它们的其他类
- CppUnit:如何立即打印故障详细信息
- 当遇到不是来自 STL 的未捕获异常时,有没有办法打印其信息?
- 我可以为 C++ 类提供不完整的标头以隐藏实现详细信息吗?
- CPP 异常获取抛出调用方的详细信息
- 内存映射 IO 概念详细信息
- 如何在文本文件中搜索员工记录(按名称)并仅显示其详细信息?
- 使用TDD时隐藏文件访问实现详细信息
- 急需有关_doserrno(MSVC)的详细信息
- 主 - Embarcadero C++生成器 10.2 中的详细信息数据集
- 如果构造函数从调用到 std::make_shared 崩溃,GDB 是否可以显示崩溃的详细信息
- 实现 std::tuple 的详细信息
- 如何使 clang 格式将所有详细信息命名空间缩进一个
- boost::exception-如何打印详细信息
- 在gdb - c++中打印有关文件流对象的详细信息