From 931a7dc1ac0dbc7e6c1083583ced915e572f5b47 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 2 Mar 2019 12:32:44 +0300 Subject: all protocols (even virtual ones) moved to the Protocols folder --- protocols/CurrencyRates/src/ComHelper.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 protocols/CurrencyRates/src/ComHelper.cpp (limited to 'protocols/CurrencyRates/src/ComHelper.cpp') diff --git a/protocols/CurrencyRates/src/ComHelper.cpp b/protocols/CurrencyRates/src/ComHelper.cpp new file mode 100644 index 0000000000..c4715892b5 --- /dev/null +++ b/protocols/CurrencyRates/src/ComHelper.cpp @@ -0,0 +1,28 @@ +#include "StdAfx.h" + +tstring ComException2Msg(_com_error& e, const tstring& rsAdditionalInfo) +{ + HRESULT hError = e.Error(); + tostringstream o; + if (false == rsAdditionalInfo.empty()) + o << rsAdditionalInfo << "\n"; + + o << e.ErrorMessage() << L" (" << std::hex << hError << L")"; + + IErrorInfo* p = e.ErrorInfo(); + CComPtr pErrorInfo(p); + if (nullptr != p) + p->Release(); + + if (pErrorInfo) + o << L"\n" << e.Description(); + + return o.str(); +} + +void ShowComError(_com_error& e, const tstring& rsAdditionalInfo) +{ + tstring sErrorMsg = ComException2Msg(e, rsAdditionalInfo); + LogIt(sErrorMsg); + CurrencyRates_MessageBox(nullptr, sErrorMsg.c_str(), MB_OK | MB_ICONERROR); +} -- cgit v1.2.3