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/VirtualBox4
Files:
2 edited

Legend:

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

    r10515 r11228  
    302302                           const QString &errorMsg);
    303303
     304    static QString formatRC (HRESULT aRC);
     305
    304306    static QString formatErrorInfo (const COMErrorInfo &aInfo,
    305307                                    HRESULT aWrapperRC = S_OK);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp

    r11227 r11228  
    20032003}
    20042004
     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 */
     2016QString 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
    20052055/* static */
    20062056QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo,
     
    20352085        bool haveComponent = true;
    20362086        bool haveInterfaceID = true;
    2037 #else // !Q_WS_WIN
     2087#else /* defined (Q_WS_WIN) */
    20382088        haveResultCode = true;
    20392089        bool haveComponent = aInfo.isFullAvailable();
     
    20432093        if (haveResultCode)
    20442094        {
    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&nbsp;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>")
    20642096                .arg (tr ("Result&nbsp;Code: ", "error info"))
    2065                 .arg (QString().sprintf ("%08X", uint (aInfo.resultCode())));
     2097                .arg (formatRC (aInfo.resultCode()));
    20662098        }
    20672099
     
    20922124        (!haveResultCode || aWrapperRC != aInfo.resultCode()))
    20932125    {
    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&nbsp;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>")
    21132127            .arg (tr ("Callee&nbsp;RC: ", "error info"))
    2114             .arg (QString().sprintf ("%08X", uint (aWrapperRC)));
    2115     }
     2128            .arg (formatRC (aWrapperRC));
     2129    }
     2130
    21162131    formatted += "</table>";
    21172132
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