Changeset 11228 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 7, 2008 7:04:53 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r8917 r11228 296 296 const QString &errorMsg); 297 297 298 static QString formatRC (HRESULT aRC); 299 298 300 static QString formatErrorInfo (const COMErrorInfo &aInfo, 299 301 HRESULT aWrapperRC = S_OK); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r8981 r11228 1990 1990 } 1991 1991 1992 /** 1993 * Formats the given COM result code as a human-readable string. 1994 * 1995 * If a mnemonic name for the given result code is found, a string in format 1996 * "MNEMONIC_NAME (0x12345678)" is returned where the hex number is the result 1997 * code as is. If no mnemonic name is found, then the raw hex number only is 1998 * returned (w/o parenthesis). 1999 * 2000 * @param aRC COM result code to format. 2001 */ 2002 /* static */ 2003 QString VBoxProblemReporter::formatRC (HRESULT aRC) 2004 { 2005 QString str; 2006 2007 PCRTCOMERRMSG msg = NULL; 2008 const char *errMsg = NULL; 2009 2010 /* first, try as is (only set bit 31 bit for warnings) */ 2011 if (SUCCEEDED_WARNING (aRC)) 2012 msg = RTErrCOMGet (aRC | 0x80000000); 2013 else 2014 msg = RTErrCOMGet (aRC); 2015 2016 if (msg != NULL) 2017 errMsg = msg->pszDefine; 2018 2019 #if defined (Q_WS_WIN) 2020 2021 PCRTWINERRMSG winMsg = NULL; 2022 2023 /* if not found, try again using RTErrWinGet with masked off top 16bit */ 2024 if (msg == NULL) 2025 { 2026 winMsg = RTErrWinGet (aRC & 0xFFFF); 2027 2028 if (winMsg != NULL) 2029 errMsg = winMsg->pszDefine; 2030 } 2031 2032 #endif 2033 2034 if (errMsg != NULL && *errMsg != '\0') 2035 str.sprintf ("%s (0x%08X)", errMsg, aRC); 2036 else 2037 str.sprintf ("0x%08X", aRC); 2038 2039 return str; 2040 } 2041 1992 2042 /* static */ 1993 2043 QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo, … … 2022 2072 bool haveComponent = true; 2023 2073 bool haveInterfaceID = true; 2024 #else / / !Q_WS_WIN2074 #else /* defined (Q_WS_WIN) */ 2025 2075 haveResultCode = true; 2026 2076 bool haveComponent = aInfo.isFullAvailable(); … … 2030 2080 if (haveResultCode) 2031 2081 { 2032 #if defined (Q_WS_WIN) 2033 /* format the error code */ 2034 PCRTWINERRMSG msg = NULL; 2035 /* first, try as is (only set bit 31 bit for warnings) */ 2036 if (SUCCEEDED_WARNING (aInfo.resultCode())) 2037 msg = RTErrWinGet (aInfo.resultCode() | 0x80000000); 2038 else 2039 msg = RTErrWinGet (aInfo.resultCode()); 2040 /* try again with masked off top 16bit if not found */ 2041 if (msg == NULL || !msg->iCode) 2042 msg = RTErrWinGet (aInfo.resultCode() & 0xFFFF); 2043 if (msg != NULL) 2044 formatted += QString ("<tr><td>%1</td><td><tt>%2 (0x%3)</tt></td></tr>") 2045 .arg (tr ("Result Code: ", "error info")) 2046 .arg (msg->pszDefine) 2047 .arg (QString().sprintf ("%08X", uint (aInfo.resultCode()))); 2048 else 2049 #endif 2050 formatted += QString ("<tr><td>%1</td><td><tt>0x%2</tt></td></tr>") 2082 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>") 2051 2083 .arg (tr ("Result Code: ", "error info")) 2052 .arg ( QString().sprintf ("%08X", uint (aInfo.resultCode())));2084 .arg (formatRC (aInfo.resultCode())); 2053 2085 } 2054 2086 … … 2079 2111 (!haveResultCode || aWrapperRC != aInfo.resultCode())) 2080 2112 { 2081 #if defined (Q_WS_WIN) 2082 /* format the error code */ 2083 PCRTWINERRMSG msg = NULL; 2084 /* first, try as is (only set bit 31 bit for warnings) */ 2085 if (SUCCEEDED_WARNING (aWrapperRC)) 2086 msg = RTErrWinGet (aWrapperRC | 0x80000000); 2087 else 2088 msg = RTErrWinGet (aWrapperRC); 2089 /* try again with masked off top 16bit if not found */ 2090 if (msg == NULL || !msg->iCode) 2091 msg = RTErrWinGet (aWrapperRC & 0xFFFF); 2092 if (msg != NULL) 2093 formatted += QString ("<tr><td>%1</td><td><tt>%2 (0x%3)</tt></td></tr>") 2094 .arg (tr ("Callee RC: ", "error info")) 2095 .arg (msg->pszDefine) 2096 .arg (QString().sprintf ("%08X", uint (aWrapperRC))); 2097 else 2098 #endif 2099 formatted += QString ("<tr><td>%1</td><td><tt>0x%2</tt></td></tr>") 2113 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>") 2100 2114 .arg (tr ("Callee RC: ", "error info")) 2101 .arg (QString().sprintf ("%08X", uint (aWrapperRC))); 2102 } 2115 .arg (formatRC (aWrapperRC)); 2116 } 2117 2103 2118 formatted += "</table>"; 2104 2119
Note:
See TracChangeset
for help on using the changeset viewer.