VirtualBox

Changeset 92483 in vbox


Ignore:
Timestamp:
Nov 17, 2021 5:35:55 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10148: Extend UIErrorString with possibility to prepare simplified error strings.

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

Legend:

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

    r90967 r92483  
    136136
    137137/* static */
     138QString UIErrorString::simplifiedErrorInfo(const COMErrorInfo &comInfo, HRESULT wrapperRC /* = S_OK */)
     139{
     140    return UIErrorString::errorInfoToSimpleString(comInfo, wrapperRC);
     141}
     142
     143/* static */
     144QString UIErrorString::simplifiedErrorInfo(const COMBaseWithEI &comWrapper)
     145{
     146    Assert(comWrapper.lastRC() != S_OK);
     147    return simplifiedErrorInfo(comWrapper.errorInfo(), comWrapper.lastRC());
     148}
     149
     150/* static */
    138151QString UIErrorString::errorInfoToString(const COMErrorInfo &comInfo, HRESULT wrapperRC)
    139152{
     
    218231}
    219232
     233/* static */
     234QString UIErrorString::errorInfoToSimpleString(const COMErrorInfo &comInfo, HRESULT wrapperRC /* = S_OK */)
     235{
     236    /* Compose complex details string with text and status code: */
     237    QString strFormatted;
     238
     239    /* Check if details text is NOT empty: */
     240    const QString strDetailsInfo = comInfo.text();
     241    if (!strDetailsInfo.isEmpty())
     242        strFormatted += strDetailsInfo;
     243
     244    /* Check if we have result code: */
     245    bool fHaveResultCode = false;
     246
     247    if (comInfo.isBasicAvailable())
     248    {
     249#ifdef VBOX_WS_WIN
     250        fHaveResultCode = comInfo.isFullAvailable();
     251#else
     252        fHaveResultCode = true;
     253#endif
     254
     255        if (fHaveResultCode)
     256            strFormatted += "; " + QString("Result Code: ") + formatRCFull(comInfo.resultCode());
     257    }
     258
     259    if (   FAILED(wrapperRC)
     260        && (!fHaveResultCode || wrapperRC != comInfo.resultCode()))
     261        strFormatted += "; " + QString("Callee RC: ") + formatRCFull(wrapperRC);
     262
     263    /* Check if we have next error queued: */
     264    if (comInfo.next())
     265        strFormatted += "; " + errorInfoToSimpleString(*comInfo.next());
     266
     267    return strFormatted;
     268}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIErrorString.h

    r82968 r92483  
    5858    static QString formatErrorInfo(const COMResult &comRc);
    5959
     60    /** Returns simplified error information for passed @a comInfo and @a wrapperRC. */
     61    static QString simplifiedErrorInfo(const COMErrorInfo &comInfo, HRESULT wrapperRC = S_OK);
     62    /** Returns simplified error information for passed @a comWrapper. */
     63    static QString simplifiedErrorInfo(const COMBaseWithEI &comWrapper);
     64
    6065private:
    6166
    6267    /** Converts passed @a comInfo and @a wrapperRC to string. */
    6368    static QString errorInfoToString(const COMErrorInfo &comInfo, HRESULT wrapperRC = S_OK);
     69
     70    /** Converts passed @a comInfo and @a wrapperRC to simplified string. */
     71    static QString errorInfoToSimpleString(const COMErrorInfo &comInfo, HRESULT wrapperRC = S_OK);
    6472};
    6573
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