Changeset 11228 in vbox for trunk/src/VBox/Frontends/VirtualBox4
- Timestamp:
- Aug 7, 2008 7:04:53 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxProblemReporter.h
r10515 r11228 302 302 const QString &errorMsg); 303 303 304 static QString formatRC (HRESULT aRC); 305 304 306 static QString formatErrorInfo (const COMErrorInfo &aInfo, 305 307 HRESULT aWrapperRC = S_OK); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp
r11227 r11228 2003 2003 } 2004 2004 2005 /** 2006 * Formats the given COM result code as a human-readable string. 2007 * 2008 * If a mnemonic name for the given result code is found, a string in format 2009 * "MNEMONIC_NAME (0x12345678)" is returned where the hex number is the result 2010 * code as is. If no mnemonic name is found, then the raw hex number only is 2011 * returned (w/o parenthesis). 2012 * 2013 * @param aRC COM result code to format. 2014 */ 2015 /* static */ 2016 QString VBoxProblemReporter::formatRC (HRESULT aRC) 2017 { 2018 QString str; 2019 2020 PCRTCOMERRMSG msg = NULL; 2021 const char *errMsg = NULL; 2022 2023 /* first, try as is (only set bit 31 bit for warnings) */ 2024 if (SUCCEEDED_WARNING (aRC)) 2025 msg = RTErrCOMGet (aRC | 0x80000000); 2026 else 2027 msg = RTErrCOMGet (aRC); 2028 2029 if (msg != NULL) 2030 errMsg = msg->pszDefine; 2031 2032 #if defined (Q_WS_WIN) 2033 2034 PCRTWINERRMSG winMsg = NULL; 2035 2036 /* if not found, try again using RTErrWinGet with masked off top 16bit */ 2037 if (msg == NULL) 2038 { 2039 winMsg = RTErrWinGet (aRC & 0xFFFF); 2040 2041 if (winMsg != NULL) 2042 errMsg = winMsg->pszDefine; 2043 } 2044 2045 #endif 2046 2047 if (errMsg != NULL && *errMsg != '\0') 2048 str.sprintf ("%s (0x%08X)", errMsg, aRC); 2049 else 2050 str.sprintf ("0x%08X", aRC); 2051 2052 return str; 2053 } 2054 2005 2055 /* static */ 2006 2056 QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo, … … 2035 2085 bool haveComponent = true; 2036 2086 bool haveInterfaceID = true; 2037 #else / / !Q_WS_WIN2087 #else /* defined (Q_WS_WIN) */ 2038 2088 haveResultCode = true; 2039 2089 bool haveComponent = aInfo.isFullAvailable(); … … 2043 2093 if (haveResultCode) 2044 2094 { 2045 #if defined (Q_WS_WIN) 2046 /* format the error code */ 2047 PCRTWINERRMSG msg = NULL; 2048 /* first, try as is (only set bit 31 bit for warnings) */ 2049 if (SUCCEEDED_WARNING (aInfo.resultCode())) 2050 msg = RTErrWinGet (aInfo.resultCode() | 0x80000000); 2051 else 2052 msg = RTErrWinGet (aInfo.resultCode()); 2053 /* try again with masked off top 16bit if not found */ 2054 if (msg == NULL || !msg->iCode) 2055 msg = RTErrWinGet (aInfo.resultCode() & 0xFFFF); 2056 if (msg != NULL) 2057 formatted += QString ("<tr><td>%1</td><td><tt>%2 (0x%3)</tt></td></tr>") 2058 .arg (tr ("Result Code: ", "error info")) 2059 .arg (msg->pszDefine) 2060 .arg (QString().sprintf ("%08X", uint (aInfo.resultCode()))); 2061 else 2062 #endif 2063 formatted += QString ("<tr><td>%1</td><td><tt>0x%2</tt></td></tr>") 2095 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>") 2064 2096 .arg (tr ("Result Code: ", "error info")) 2065 .arg ( QString().sprintf ("%08X", uint (aInfo.resultCode())));2097 .arg (formatRC (aInfo.resultCode())); 2066 2098 } 2067 2099 … … 2092 2124 (!haveResultCode || aWrapperRC != aInfo.resultCode())) 2093 2125 { 2094 #if defined (Q_WS_WIN) 2095 /* format the error code */ 2096 PCRTWINERRMSG msg = NULL; 2097 /* first, try as is (only set bit 31 bit for warnings) */ 2098 if (SUCCEEDED_WARNING (aWrapperRC)) 2099 msg = RTErrWinGet (aWrapperRC | 0x80000000); 2100 else 2101 msg = RTErrWinGet (aWrapperRC); 2102 /* try again with masked off top 16bit if not found */ 2103 if (msg == NULL || !msg->iCode) 2104 msg = RTErrWinGet (aWrapperRC & 0xFFFF); 2105 if (msg != NULL) 2106 formatted += QString ("<tr><td>%1</td><td><tt>%2 (0x%3)</tt></td></tr>") 2107 .arg (tr ("Callee RC: ", "error info")) 2108 .arg (msg->pszDefine) 2109 .arg (QString().sprintf ("%08X", uint (aWrapperRC))); 2110 else 2111 #endif 2112 formatted += QString ("<tr><td>%1</td><td><tt>0x%2</tt></td></tr>") 2126 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>") 2113 2127 .arg (tr ("Callee RC: ", "error info")) 2114 .arg (QString().sprintf ("%08X", uint (aWrapperRC))); 2115 } 2128 .arg (formatRC (aWrapperRC)); 2129 } 2130 2116 2131 formatted += "</table>"; 2117 2132
Note:
See TracChangeset
for help on using the changeset viewer.