1
我正在使用Windows 8应用程序(C++)。我使用了Windows 8样本集合中的httpclient类。如何捕捉异常[C++/CX]
inline void CheckHResult(HRESULT hResult)
{
if (hResult == E_ABORT)
{
concurrency::cancel_current_task();
}
else if (FAILED(hResult))
{
throw Platform::Exception::CreateException(hResult);
}
}
当应用程序未连接到互联网时,此函数会引发异常。我试图在下面的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.
有什么我做错了吗?
非常感谢您的帮助。学习像你这样的知识渊博的人是很好的:) – 2013-04-07 12:09:03