[commit] r1127 - trunk/GME/Common

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Jan 12 12:53:55 CST 2011


Author: ksmyth
Date: Wed Jan 12 12:53:55 2011
New Revision: 1127

Log:
Use FormatMessage to get HRESULT text since stale values may be in GetErrorInfo

Modified:
   trunk/GME/Common/CommonError.cpp

Modified: trunk/GME/Common/CommonError.cpp
==============================================================================
--- trunk/GME/Common/CommonError.cpp	Tue Jan 11 16:01:42 2011	(r1126)
+++ trunk/GME/Common/CommonError.cpp	Wed Jan 12 12:53:55 2011	(r1127)
@@ -151,7 +151,7 @@
 	}
 }
 
-void GetErrorInfo(BSTR *desc)
+bool GetErrorInfo(BSTR *desc)
 {
 	ASSERT( desc != NULL );
 
@@ -166,7 +166,9 @@
 	catch(hresult_exception &)
 	{
 		// do nothing
+		return false;
 	}
+	return true;
 }
 
 void GetErrorInfo(HRESULT hr, BSTR *p)
@@ -185,5 +187,16 @@
 		*p = SysAllocString(desc);
 	}
 	else
-		GetErrorInfo(p);
+	{
+		LPWSTR errorText = NULL;
+		FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_IGNORE_INSERTS,  
+		   NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&errorText, 0, NULL);
+		if (errorText != NULL) {
+			SysFreeString(*p);
+			*p = SysAllocString(errorText);
+			LocalFree(errorText);
+		} else {
+			GetErrorInfo(p);
+		}
+	}
 }


More information about the gme-commit mailing list