Created
November 6, 2014 19:30
-
-
Save gchudnov/7f723b9ed5772bcf7479 to your computer and use it in GitHub Desktop.
Win32 COM exception handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
try { | |
// ... | |
} catch(_com_error &e) { | |
_bstr_t source(e.Source()); | |
_bstr_t description(e.Description()); | |
std::wcout << L "Error: " << e.Error() << std::endl; | |
std::wcout << L "ErrorMessage: " << e.ErrorMessage() << std::endl; | |
std::wcout << L "Source: " << (!source ? L"" : static_cast <const wchar_t*>(source)) << std::endl; | |
std::wcout << L "Description: " <<(!description ? L"" : static_cast <const wchar_t*>(description)) << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment