Esempio n. 1
0
STDMETHODIMP 
HSPErrorSink::ErrorOccurred(const UINT8 unSeverity,  
                            const ULONG32   ulHXCode,
                            const ULONG32   ulUserCode,
                            const char* pUserString,
                            const char* pMoreInfoURL
                            )
{
    char HXDefine[256]; /* Flawfinder: ignore */

    // Store the code, so we can return it from main()
    m_splayer->m_Error = ulHXCode;

    ConvertErrorToString(ulHXCode, HXDefine, 256);

    m_splayer->STDOUT("Report(%d, %ld, \"%s\", %ld, \"%s\", \"%s\")\n",
                      unSeverity,
                      ulHXCode,
                      (pUserString && *pUserString) ? pUserString : "(NULL)",
                      ulUserCode,
                      (pMoreInfoURL && *pMoreInfoURL) ? pMoreInfoURL : "(NULL)",
                      HXDefine);

    return HXR_OK;
}
Esempio n. 2
0
//-------------------------------------------------------------------//
// GetComError()																		//
//-------------------------------------------------------------------//
// Reports on common errors to COM requests.
// Feel free to add error handling for other values as needed.
// They are typically found in WinError.h.
//-------------------------------------------------------------------//
ustring GetComError( HRESULT hInterfaceRequestResult, DWORD dwLastError )
{
	ustring strMsg;
	switch( hInterfaceRequestResult )
	{
		case E_INVALIDARG:
			strMsg = _T("An invalid argument was provided");
			break;
		case REGDB_E_CLASSNOTREG:
			strMsg = _T("Class not found to be registered");
			break;
		case CLASS_E_NOAGGREGATION:
			strMsg = _T("Illegal aggregation attempted");
			break;
		case CO_S_NOTALLINTERFACES:
			strMsg = _T("Not all interfaces were found");
			break;
		case E_NOINTERFACE:
			strMsg = _T("No interface found");
			break;
		case CO_E_NOTINITIALIZED:
		case RPC_E_THREAD_NOT_INIT:
			strMsg = _T("COM was found to not have been initialized [via CoInitialize()] in your process or thread");
			break;
		
		// --------------
		// TO DO
		
		// I have found this to be the result when a COM interface "disappears out 
		// from under us" due to the underlying COM object being destroyed.
		// If this seems to be the common consensus, add an appropriate msg here.
		// For now, just fall through to the "unknown error".
		case E_OUTOFMEMORY:		
			ASSERT( false );
										
		// --------------
		
		default:
		{
			if ( dwLastError == ERROR_SUCCESS )
			{
				strMsg = _T("There was an unknown COM error (error ");
				strMsg.AppendNumber( (Long)hInterfaceRequestResult );
				strMsg += _T(" - see WinError.h for more details)");

			} else
			{
				// Pull out the stops!  Call GetLastError() etc.
				strMsg = ConvertErrorToString( dwLastError );
				
				// Get rid of the period and newline.
				strMsg.resize( strMsg.size() - 2 );
			}
		}
	}

	return strMsg;	
}
Esempio n. 3
0
STDMETHODIMP 
HSPErrorSink::ErrorOccurred(const UINT8 unSeverity,  
                            const ULONG32   ulHXCode,
                            const ULONG32   ulUserCode,
                            const char* pUserString,
                            const char* pMoreInfoURL
                            )
{
    char HXDefine[256]; /* Flawfinder: ignore */

    // Store the code, so we can return it from main()
    m_splayer->m_Error = ulHXCode;

    switch (unSeverity)
    {
       case HXLOG_NOTICE:
       case HXLOG_INFO:
          m_splayer->notifyUser(ulHXCode,
                                (pUserString && *pUserString) ? pUserString : "",
                                (pMoreInfoURL && *pMoreInfoURL) ? pMoreInfoURL : "" );
          break;
       case HXLOG_WARNING:
       case HXLOG_ERR:
       case HXLOG_CRIT:
       case HXLOG_ALERT:
       case HXLOG_EMERG:
          m_splayer->interruptUser(ulHXCode,
                                   (pUserString && *pUserString) ? pUserString : "",
                                   (pMoreInfoURL && *pMoreInfoURL) ? pMoreInfoURL : "" );
          break;
    }
    ConvertErrorToString(ulHXCode, HXDefine, 256);

    m_splayer->print2stdout("Report(%d, %ld, \"%s\", %ld, \"%s\", \"%s\")\n",
                      unSeverity,
                      ulHXCode,
                      (pUserString && *pUserString) ? pUserString : "(NULL)",
                      ulUserCode,
                      (pMoreInfoURL && *pMoreInfoURL) ? pMoreInfoURL : "(NULL)",
                      HXDefine);

    return HXR_OK;
}