void FOpenGLDrv::CheckError(const char* FILE, int LINE) { GLenum Error = glGetError(); if (Error != GL_NO_ERROR) { std::cout << "OpenGL Error: " << FILE << " At Line: " << LINE << ", Error-Code=" << Error << " --- " << LookupErrorCode(Error) << std::endl; } }
//***************************************************************************** //* Function Name: HandleFacilityInternetComErrorException //* Description: Special handling for errors with a facility of //* FACILITY_INTERNET. //***************************************************************************** static bool HandleFacilityInternetComErrorException (const _com_error& p_ce) { bool l_bHandled = false; // In nearly all cases that I have observed so far, // when the failure HRESULT has a facility of FACILITY_INTERNET, // the Description/ErrorMessage is just a generic string // containing the error code rather than a meaningful description. // However, the corresponding description is often available in the // MESSAGETABLE resource of one of the system DLLs associated with // internet functionality. Therefore, try to look up the error code // in these system DLLs. If the lookup is successful then set new rich // error information. In addition, we set the Source and GUID properties // of the rich error information according to the active COM method's // CLSID and IID. try { // We are only interested in FACILITY_INTERNET. if (HRESULT_FACILITY (p_ce.Error ()) != FACILITY_INTERNET) { return false; } _bstr_t l_sbstrDescription = p_ce.Description (); // We are not interested if we already have non-empty rich error // information descriptive text. if (l_sbstrDescription.length () > 0) { return false; } LPCTSTR l_lpszErrorMessage = p_ce.ErrorMessage(); // We are not interested unless the system error message begins // with "Unknown error". if (l_lpszErrorMessage != NULL) { static const TCHAR UNKNOWN_ERROR[] = _T("Unknown error"); if (_tcsnicmp (l_lpszErrorMessage, UNKNOWN_ERROR, _tcslen (UNKNOWN_ERROR)) != 0) { return false; } } // If we get to here, then there is no description and no error message. // Let's try to lookup the error code in the MESSAGETABLE resources of // a few system DLLs in order to try to find a decent error message. static LPCTSTR s_rglpszDLLs[] = { _T("urlmon.dll"), _T("wininet.dll"), _T("winhttp.dll"), _T("msxml3r.dll") }; static UINT s_uNumDLLs = sizeof (s_rglpszDLLs) / sizeof (*s_rglpszDLLs); bool l_bFound = false; TCHAR l_szDescription[256] = {0}; l_bFound = LookupErrorCode ( p_ce.Error (), s_rglpszDLLs, s_uNumDLLs, l_szDescription, 256); if (!l_bFound) { l_bFound = LookupErrorCode ( HRESULT_CODE (p_ce.Error ()), s_rglpszDLLs, s_uNumDLLs, l_szDescription, 256); } if (l_bFound) { CLSID l_clsid = GUID_NULL; IID l_iid = GUID_NULL; CActiveMethodGUIDs::Get (l_clsid, l_iid); USES_CONVERSION; HRESULT l_hr; // Create and populate a standard error object. ICreateErrorInfoPtr l_spCreateErrorInfo; l_hr = ::CreateErrorInfo (&l_spCreateErrorInfo); if (FAILED (l_hr)) _com_issue_error (l_hr); // Set the Description property. l_hr = l_spCreateErrorInfo->SetDescription (T2OLE (l_szDescription)); if (FAILED (l_hr)) _com_issue_error (l_hr); // Get the ProgID corresponding to rclsid. LPOLESTR l_lpoleszProgID = NULL; l_hr = ::ProgIDFromCLSID (l_clsid, &l_lpoleszProgID); if (FAILED (l_hr)) _com_issue_error (l_hr); // Set the Source property. l_hr = l_spCreateErrorInfo->SetSource (l_lpoleszProgID); ::CoTaskMemFree (l_lpoleszProgID); l_lpoleszProgID = NULL; if (FAILED (l_hr)) _com_issue_error (l_hr); // Set the GUID property. l_hr = l_spCreateErrorInfo->SetGUID (l_iid); if (FAILED (l_hr)) _com_issue_error (l_hr); IErrorInfoPtr l_spErrorInfo (l_spCreateErrorInfo); // SetErrorInfo() causes the COM run-time to call AddRef() // on the error object. This will be the only outstanding // reference by the end of this function. (void) ::SetErrorInfo (0 /* dwReserved */, l_spErrorInfo); l_bHandled = true; } } catch (const _com_error&) { } return l_bHandled; }