Windows 8 如何捕获异常[C+;+;/CX]
我正在使用Windows8应用程序(C++)。我使用了Windows8示例集合中的httpclient类Windows 8 如何捕获异常[C+;+;/CX],windows-8,exception-handling,windows-store-apps,c++-cx,Windows 8,Exception Handling,Windows Store Apps,C++ Cx,我正在使用Windows8应用程序(C++)。我使用了Windows8示例集合中的httpclient类 inline void CheckHResult(HRESULT hResult) { if (hResult == E_ABORT) { concurrency::cancel_current_task(); } else if (FAILED(hResult)) { throw Platform::Exception
inline void CheckHResult(HRESULT hResult)
{
if (hResult == E_ABORT)
{
concurrency::cancel_current_task();
}
else if (FAILED(hResult))
{
throw Platform::Exception::CreateException(hResult);
}
}
当应用程序未连接到internet时,此函数引发异常。我正试图捕捉以下lambda中的异常,如下所示
return completionTask.then([this, stringCallback](tuple<HRESULT, wstring> resultTuple)
{
try
{
CheckHResult(std::get<0>(resultTuple));
}
catch(Exception^ ex)
{
}
return std::get<1>(resultTuple);
});
有什么我做错了吗?第一次机会异常不一定表示代码有问题,它与未捕获的异常不同 描述什么是第一次机会异常,只是向调试器发出已抛出异常的通知,无论稍后是否捕获该异常 在调试应用程序时,只要此时遇到异常,就会通知调试器,应用程序将挂起,调试器将决定如何处理该异常第一次通过此机制称为“第一次机会”异常。根据调试器的配置,它将恢复应用程序并传递异常,或者将应用程序挂起并进入调试模式如果应用程序处理异常,它将继续正常运行。
非常感谢你的帮助。向你这样有知识的人学习真是太好了:)
First-chance exception at 0x77194B32 in Sample.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x08C7EDF4. HRESULT:0x800C0005
If there is a handler for this exception, the program may be safely continued.