VirtualBox

Ignore:
Timestamp:
Mar 25, 2015 12:24:45 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Message-center: Adding some internal error formatting API.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r54794 r54937  
    24602460    const char *errMsg = NULL;
    24612461
    2462     /* first, try as is (only set bit 31 bit for warnings) */
     2462    /* First, try as is (only set bit 31 bit for warnings): */
    24632463    if (SUCCEEDED_WARNING(rc))
    24642464        msg = RTErrCOMGet(rc | 0x80000000);
     
    24692469        errMsg = msg->pszDefine;
    24702470
    2471 #if defined (Q_WS_WIN)
    2472 
     2471#ifdef Q_WS_WIN
    24732472    PCRTWINERRMSG winMsg = NULL;
    24742473
    2475     /* if not found, try again using RTErrWinGet with masked off top 16bit */
     2474    /* If not found, try again using RTErrWinGet with masked off top 16bit: */
    24762475    if (msg == NULL)
    24772476    {
     
    24812480            errMsg = winMsg->pszDefine;
    24822481    }
    2483 
    2484 #endif
     2482#endif /* Q_WS_WIN */
     2483
     2484    if (errMsg != NULL && *errMsg != '\0')
     2485        str.sprintf("%s", errMsg);
     2486
     2487    return str;
     2488}
     2489
     2490/* static */
     2491QString UIMessageCenter::formatRCFull(HRESULT rc)
     2492{
     2493    QString str;
     2494
     2495    PCRTCOMERRMSG msg = NULL;
     2496    const char *errMsg = NULL;
     2497
     2498    /* First, try as is (only set bit 31 bit for warnings): */
     2499    if (SUCCEEDED_WARNING(rc))
     2500        msg = RTErrCOMGet(rc | 0x80000000);
     2501    else
     2502        msg = RTErrCOMGet(rc);
     2503
     2504    if (msg != NULL)
     2505        errMsg = msg->pszDefine;
     2506
     2507#ifdef Q_WS_WIN
     2508    PCRTWINERRMSG winMsg = NULL;
     2509
     2510    /* If not found, try again using RTErrWinGet with masked off top 16bit: */
     2511    if (msg == NULL)
     2512    {
     2513        winMsg = RTErrWinGet(rc & 0xFFFF);
     2514
     2515        if (winMsg != NULL)
     2516            errMsg = winMsg->pszDefine;
     2517    }
     2518#endif /* Q_WS_WIN */
    24852519
    24862520    if (errMsg != NULL && *errMsg != '\0')
     
    25082542                   "<tr><td>%1</td><td><tt>%2</tt></td></tr></table>")
    25092543                   .arg(tr("Result&nbsp;Code: ", "error info"))
    2510                    .arg(formatRC(progress.GetResultCode()))
     2544                   .arg(formatRCFull(progress.GetResultCode()))
    25112545                   .prepend("<!--EOM-->") /* move to details */;
    25122546}
     
    27292763            formatted += QString("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
    27302764                .arg(tr("Result&nbsp;Code: ", "error info"))
    2731                 .arg(formatRC(info.resultCode()));
     2765                .arg(formatRCFull(info.resultCode()));
    27322766        }
    27332767
     
    27602794        formatted += QString("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
    27612795            .arg(tr("Callee&nbsp;RC: ", "error info"))
    2762             .arg(formatRC(wrapperRC));
     2796            .arg(formatRCFull(wrapperRC));
    27632797    }
    27642798
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r54794 r54937  
    360360    /* API: Static helpers: */
    361361    static QString formatRC(HRESULT rc);
     362    static QString formatRCFull(HRESULT rc);
    362363    static QString formatErrorInfo(const CProgress &progress);
    363364    static QString formatErrorInfo(const COMErrorInfo &info, HRESULT wrapperRC = S_OK);
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