VirtualBox

儲存庫 vbox 的更動 89720


忽略:
時間撮記:
2021-6-15 下午06:53:58 (4 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
145171
訊息:

com/errorprint: Teach it how to deal with warnings (print the message and continue as usual), using the appropriate flagging as warnings. bugref:3582

位置:
trunk
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/VBox/com/errorprint.h

    r86141 r89720  
    4848// compiled only once for all front-ends
    4949void GluePrintErrorInfo(const com::ErrorInfo &info);
    50 void GluePrintErrorContext(const char *pcszContext, const char *pcszSourceFile, uint32_t uLine);
     50void GluePrintErrorContext(const char *pcszContext, const char *pcszSourceFile, uint32_t uLine, bool fWarning = false);
    5151void GluePrintRCMessage(HRESULT rc);
    5252void GlueHandleComError(ComPtr<IUnknown> iface, const char *pcszContext, HRESULT rc, const char *pcszSourceFile, uint32_t uLine);
     
    8888    if (1) { \
    8989        type hrc = iface->method; \
    90         if (SUCCEEDED(hrc)) \
     90        if (SUCCEEDED(hrc) && !SUCCEEDED_WARNING(hrc)) \
    9191        { /*likely*/ } \
    9292        else \
    9393        { \
    9494            com::GlueHandleComError(iface, #method, (hrc), __FILE__, __LINE__); \
    95             stmtError; \
     95            if (!SUCCEEDED_WARNING(hrc)) \
     96            { \
     97                stmtError; \
     98            } \
    9699        } \
    97100    } else do { /* nothing */ } while (0)
     
    112115    do { \
    113116        rc = iface->method; \
    114         if (FAILED(rc)) \
     117        if (FAILED(rc) || SUCCEEDED_WARNING(rc)) \
    115118            com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
    116119    } while (0)
     
    144147    do { \
    145148        rc = iface->method; \
    146         if (FAILED(rc)) \
    147         { \
    148             com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
    149             stmt; \
     149        if (FAILED(rc) || SUCCEEDED_WARNING(rc)) \
     150        { \
     151            com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
     152            if (!SUCCEEDED_WARNING(rc) \
     153            { \
     154                stmt; \
     155            } \
    150156        } \
    151157    } while (0)
     
    183189    ({ \
    184190        rc = iface->method; \
    185         if (FAILED(rc)) \
    186         { \
    187             com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
    188             break; \
     191        if (FAILED(rc) || SUCCEEDED_WARNING(rc)) \
     192        { \
     193            com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
     194            if (!SUCCEEDED_WARNING(rc)) \
     195                break; \
    189196        } \
    190197    })
     
    197204        { \
    198205            com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
    199             break; \
     206            if (!SUCCEEDED_WARNING(rc)) \
     207                break; \
    200208        } \
    201209    } \
     
    243251    do { \
    244252        rc = iface->method; \
    245         if (FAILED(rc)) \
    246         { \
    247             com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
    248             return (ret); \
     253        if (FAILED(rc) || SUCCEEDED_WARNING(rc)) \
     254        { \
     255            com::GlueHandleComError(iface, #method, rc, __FILE__, __LINE__); \
     256            if (!SUCCEEDED_WARNING(rc)) \
     257                return (ret); \
    249258        } \
    250259    } while (0)
  • trunk/src/VBox/Main/glue/errorprint.cpp

    r86141 r89720  
    4747    try
    4848    {
     49        HRESULT rc = S_OK;
    4950        Utf8Str str;
    5051        RTCList<Utf8Str> comp;
     
    5556                             bstrDetailsText.raw());
    5657        if (haveResultCode)
    57             comp.append(Utf8StrFmt("code %Rhrc (0x%RX32)",
    58                                    info.getResultCode(),
    59                                    info.getResultCode()));
     58        {
     59            rc = info.getResultCode();
     60            comp.append(Utf8StrFmt("code %Rhrc (0x%RX32)", rc, rc));
     61        }
    6062        if (haveComponent)
    6163            comp.append(Utf8StrFmt("component %ls",
     
    7880
    7981        // print and log
    80         RTMsgError("%s", str.c_str());
    81         Log(("ERROR: %s", str.c_str()));
     82        if (FAILED(rc))
     83        {
     84            RTMsgError("%s", str.c_str());
     85            Log(("ERROR: %s", str.c_str()));
     86        }
     87        else
     88        {
     89            RTMsgWarning("%s", str.c_str());
     90            Log(("WARNING: %s", str.c_str()));
     91        }
    8292    }
    8393    catch (std::bad_alloc &)
     
    8898}
    8999
    90 void GluePrintErrorContext(const char *pcszContext, const char *pcszSourceFile, uint32_t ulLine)
     100void GluePrintErrorContext(const char *pcszContext, const char *pcszSourceFile, uint32_t ulLine, bool fWarning /* = false */)
    91101{
    92102    // pcszSourceFile comes from __FILE__ macro, which always contains the full path,
     
    94104    // print and log
    95105    const char *pszFilenameOnly = RTPathFilename(pcszSourceFile);
    96     RTMsgError("Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly);
    97     Log(("Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly));
     106    if (!fWarning)
     107    {
     108        RTMsgError("Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly);
     109        Log(("ERROR: Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly));
     110    }
     111    else
     112    {
     113        RTMsgWarning("Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly);
     114        Log(("WARNING: Context: \"%s\" at line %d of file %s\n", pcszContext, ulLine, pszFilenameOnly));
     115    }
    98116}
    99117
     
    101119{
    102120    // print and log
    103     RTMsgError("Code %Rhra (extended info not available)\n", rc);
    104     Log(("ERROR: Code %Rhra (extended info not available)\n", rc));
     121    if (FAILED(rc))
     122    {
     123        RTMsgError("Code %Rhra (extended info not available)\n", rc);
     124        Log(("ERROR: Code %Rhra (extended info not available)\n", rc));
     125    }
     126    else
     127    {
     128        RTMsgWarning("Code %Rhra (extended info not available)\n", rc);
     129        Log(("WARNING: Code %Rhra (extended info not available)\n", rc));
     130    }
    105131}
    106132
     
    117143        {
    118144            GluePrintErrorInfo(*pInfo);
     145
     146            /* Use rc for figuring out if there were just warnings. */
     147            HRESULT rc2 = pInfo->getResultCode();
     148            if (   (SUCCEEDED_WARNING(rc) && FAILED(rc2))
     149                || (SUCCEEDED(rc) && (FAILED(rc2) || SUCCEEDED_WARNING(rc2))))
     150                rc = rc2;
    119151
    120152            pInfo = pInfo->getNext();
     
    136168
    137169    if (pcszContext != NULL || pcszSourceFile != NULL)
    138         GluePrintErrorContext(pcszContext, pcszSourceFile, ulLine);
     170        GluePrintErrorContext(pcszContext, pcszSourceFile, ulLine, SUCCEEDED_WARNING(rc));
    139171}
    140172
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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