VirtualBox

Changeset 89720 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Jun 15, 2021 6:53:58 PM (3 years ago)
Author:
vboxsync
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
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