VirtualBox

Ignore:
Timestamp:
Aug 7, 2008 7:04:53 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt: Added printing the mnemonic error code in addition to the hex number in the error boxes.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r8917 r11228  
    296296                           const QString &errorMsg);
    297297
     298    static QString formatRC (HRESULT aRC);
     299
    298300    static QString formatErrorInfo (const COMErrorInfo &aInfo,
    299301                                    HRESULT aWrapperRC = S_OK);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r8981 r11228  
    19901990}
    19911991
     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 */
     2003QString 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
    19922042/* static */
    19932043QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo,
     
    20222072        bool haveComponent = true;
    20232073        bool haveInterfaceID = true;
    2024 #else // !Q_WS_WIN
     2074#else /* defined (Q_WS_WIN) */
    20252075        haveResultCode = true;
    20262076        bool haveComponent = aInfo.isFullAvailable();
     
    20302080        if (haveResultCode)
    20312081        {
    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&nbsp;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>")
    20512083                .arg (tr ("Result&nbsp;Code: ", "error info"))
    2052                 .arg (QString().sprintf ("%08X", uint (aInfo.resultCode())));
     2084                .arg (formatRC (aInfo.resultCode()));
    20532085        }
    20542086
     
    20792111        (!haveResultCode || aWrapperRC != aInfo.resultCode()))
    20802112    {
    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&nbsp;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>")
    21002114            .arg (tr ("Callee&nbsp;RC: ", "error info"))
    2101             .arg (QString().sprintf ("%08X", uint (aWrapperRC)));
    2102     }
     2115            .arg (formatRC (aWrapperRC));
     2116    }
     2117
    21032118    formatted += "</table>";
    21042119
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette