A short time ago, I summarized the kind of caller diagnostic information you can get from exceptions thrown by C++/WinRT and wil. My colleague David Machaj reminded me that the story had improved in the time since I originally wrote the article, so it’s time for an update.
Starting in version 2.0.220929.3 of C++/WinRT, if std::
is supported, then C++/WinRT uses it to pass file and line number information to wil when a C++/WinRT exception is thrown. In practice, this happens when you compile in C++20 mode or later.
The revised table now looks like this:
 | C++/WinRT | wil | |||
---|---|---|---|---|---|
no wil/ |
with wil/ |
no C++/CX | with C++/CX | ||
throw hresult_ |
check_ |
THROW_ |
THROW_ |
||
Thrown type | hresult_ |
hresult_ |
hresult_ |
ResultÂException |
Exception^ |
Stack trace in thrown object | Yes | Yes | Yes | No | Yes |
Stack trace in thread data | Yes | Yes | Yes | Requires result_ |
Yes |
File/line number in thrown object | No | No | No | Yes | No |
Exception in wil error log | No | No | Yes | Yes | Yes |
File/line number in wil error log | No | Requires C++20 | Requires C++20 | Yes | Yes |
0 comments