如何使用set_unexpected(my_unexpected())获取有关未处理异常的信息
How to retrieve info about unhandled exception using set_unexpected(my_unexpected())?
如何获得未处理异常的信息(类型+堆栈),在某个奇怪的代码中抛出,使用以下机制:
set_unexpected (my_unexpected ()) ?
我怀疑这是不可能的。是否有其他方法如何获得异常类型,在最好的情况下,甚至调用堆栈的地方,未处理的抛出是?我又浏览了一下,发现了一些很有用的东西。
我的问题可以改写为:如何复活一个未处理的异常。下面是一个解决方案:
// resurrect gone exception here
std::string ResurrectException()
{
try
{
throw;
}
catch (const std::exception& e)
{
return e.what();
}
catch (int intEx)
{
char buffer[2];
sprintf(buffer,"%d",intEx);
std::string outStr = buffer;
return buffer;
}
catch (std::string strEx)
{
return strEx;
}
catch (char * buffEx)
{
std::string outStr = buffEx;
return outStr;
}
// } catch (my_custom_exception_type& e) {
// return e.ToString(); }
catch(...)
{
return "unknown exception!";
}
}
详情见此处
我只是想知道"获得抛出异常的地方的堆栈"这一部分。在c#标准系统中。异常类作为字符串成员携带有关堆栈的信息。不幸的是,我在c++标准系统异常中没有看到这个
相关文章:
- 在c++中实现LinkedList时,应出现未处理的错误
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 在信号处理程序中捕获C++未处理的异常并恢复应用程序
- 在C++程序中使用的迭代器中未处理的异常
- 在 ******.exe 中0x00000000772CA267 (ntdll.dll) 处未处理的异常:0xC0000
- 未处理的异常与 cudaMemcpy2D
- 处理未处理的异常更改C++
- for 循环中未处理的异常
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- 为什么此代码导致未处理的异常失败
- 瓦尔格林德:注意到但未处理的国际奥克特尔;是否有必要处理以及如何找到?
- 在OpenCV_core310.dll中使用findContours函数时,OpenCV引发未处理的异常
- 0x0F50DF58:0xC0000005:访问冲突读取位置0x0047CA04时未处理的异常
- 使用 getline 时未处理的异常
- 错误 : 异常 : 引发未处理的异常: 读取访问冲突.0xDDDDDDDD临时温度
- 核心消息传递中未处理的异常.dll在程序关闭期间
- 在 Hello World.exe 中0x0F828F0E (ucrtbased.dll) 处未处理的异常: 0xC00
- 从向量中删除元素时未处理的异常
- QML:多个键按 /发布后未处理一些键
- C++ 程序中双链表的未处理异常