VirtualBox

儲存庫 vbox 的更動 55582


忽略:
時間撮記:
2015-5-1 下午06:26:59 (10 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
99955
訊息:

VirtualBoxBase.cpp: Added setErrorVrc(vrc) and setErrorBoth(hrc,vrc...) and passed the vrc on via IVirtualBoxErrorInfo::resultDetail. This is for better understand user problems, not necessarily for dragging include/*/err.h into the Main API definition. Fact is though, that several areas in main have poor error reporting, in some places it's almost unavoidable. (Btw. include/*/err.h is solidly stable within release due to extension packs, so there is no stability issues here.)

位置:
trunk/src/VBox/Main
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r55401 r55582  
    758758                                    Utf8Str aText,
    759759                                    bool aWarning,
    760                                     bool aLogIt);
     760                                    bool aLogIt,
     761                                    LONG aResultDetail = 0);
    761762    static void clearError(void);
    762763
     
    764765    HRESULT setError(HRESULT aResultCode, const char *pcsz, ...);
    765766    HRESULT setError(const ErrorInfo &ei);
     767    HRESULT setErrorVrc(int vrc);
     768    HRESULT setErrorVrc(int vrc, const char *pcszMsgFmt, ...);
     769    HRESULT setErrorBoth(HRESULT hrc, int vrc);
     770    HRESULT setErrorBoth(HRESULT hrc, int vrc, const char *pcszMsgFmt, ...);
    766771    HRESULT setWarning(HRESULT aResultCode, const char *pcsz, ...);
    767772    HRESULT setErrorNoLog(HRESULT aResultCode, const char *pcsz, ...);
  • trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp

    r51903 r55582  
    3737#include "VirtualBoxErrorInfoImpl.h"
    3838#include "Logging.h"
     39#include "Global.h"
    3940
    4041#include "VBox/com/ErrorInfo.h"
     
    168169                                         Utf8Str aText,
    169170                                         bool aWarning,
    170                                          bool aLogIt)
     171                                         bool aLogIt,
     172                                         LONG aResultDetail /* = 0*/)
    171173{
    172174    /* whether multi-error mode is turned on */
     
    174176
    175177    if (aLogIt)
    176         LogRel(("%s [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%s} aText={%s}, preserve=%RTbool\n",
     178        LogRel(("%s [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%s} aText={%s}, preserve=%RTbool aResultDetail=%d\n",
    177179                aWarning ? "WARNING" : "ERROR",
    178180                aResultCode,
     
    182184                aText.c_str(),
    183185                aWarning,
    184                 preserve));
     186                preserve,
     187                aResultDetail));
    185188
    186189    /* these are mandatory, others -- not */
     
    259262
    260263        /* set the current error info and preserve the previous one if any */
    261         rc = info->init(aResultCode, aIID, pcszComponent, aText, curInfo);
     264        rc = info->initEx(aResultCode, aResultDetail, aIID, pcszComponent, aText, curInfo);
    262265        if (FAILED(rc)) break;
    263266
     
    303306
    304307            /* set the current error info and preserve the previous one if any */
    305             rc = info->init(aResultCode, aIID, pcszComponent, Bstr(aText), curInfo);
     308            rc = info->initEx(aResultCode, aResultDetail, aIID, pcszComponent, Bstr(aText), curInfo);
    306309            if (FAILED(rc)) break;
    307310
     
    504507
    505508/**
     509 * Converts the VBox status code a COM one and sets the error info.
     510 *
     511 * The VBox status code is made available to the API user via
     512 * IVirtualBoxErrorInfo::resultDetail attribute.
     513 *
     514 * @param   vrc             The VBox status code.
     515 * @return  COM status code appropriate for @a vrc.
     516 *
     517 * @sa      VirtualBoxBase::setError(HRESULT)
     518 */
     519HRESULT VirtualBoxBase::setErrorVrc(int vrc)
     520{
     521    return setErrorInternal(Global::vboxStatusCodeToCOM(vrc),
     522                            this->getClassIID(),
     523                            this->getComponentName(),
     524                            Utf8Str("%Rrc", vrc),
     525                            false /* aWarning */,
     526                            true /* aLogIt */,
     527                            vrc /* aResultDetail */);
     528}
     529
     530/**
     531 * Converts the VBox status code a COM one and sets the error info.
     532 *
     533 * @param   vrc             The VBox status code.
     534 * @param   pcszMsgFmt      Error message format string.
     535 * @param   ...             Argument specified in the @a pcszMsgFmt
     536 * @return  COM status code appropriate for @a vrc.
     537 *
     538 * @sa      VirtualBoxBase::setError(HRESULT, const char *, ...)
     539 */
     540HRESULT VirtualBoxBase::setErrorVrc(int vrc, const char *pcszMsgFmt, ...)
     541{
     542    va_list va;
     543    va_start(va, pcszMsgFmt);
     544    HRESULT hrc = setErrorInternal(Global::vboxStatusCodeToCOM(vrc),
     545                                   this->getClassIID(),
     546                                   this->getComponentName(),
     547                                   Utf8Str(pcszMsgFmt, va),
     548                                   false /* aWarning */,
     549                                   true /* aLogIt */,
     550                                   vrc /* aResultDetail */);
     551    va_end(va);
     552    return hrc;
     553}
     554
     555/**
     556 * Sets error info with both a COM status and an VBox status code.
     557 *
     558 * The VBox status code is made available to the API user via
     559 * IVirtualBoxErrorInfo::resultDetail attribute.
     560 *
     561 * @param   hrc             The COM status code to return.
     562 * @param   vrc             The VBox status code.
     563 * @return  Most likely @hrc, see setErrorInternal.
     564 *
     565 * @sa      VirtualBoxBase::setError(HRESULT)
     566 */
     567HRESULT VirtualBoxBase::setErrorBoth(HRESULT hrc, int vrc)
     568{
     569    return setErrorInternal(hrc,
     570                            this->getClassIID(),
     571                            this->getComponentName(),
     572                            Utf8Str("%Rrc", vrc),
     573                            false /* aWarning */,
     574                            true /* aLogIt */,
     575                            vrc /* aResultDetail */);
     576}
     577
     578/**
     579 * Sets error info with a message and both a COM status and an VBox status code.
     580 *
     581 * The VBox status code is made available to the API user via
     582 * IVirtualBoxErrorInfo::resultDetail attribute.
     583 *
     584 * @param   hrc             The COM status code to return.
     585 * @param   vrc             The VBox status code.
     586 * @param   pcszMsgFmt      Error message format string.
     587 * @param   ...             Argument specified in the @a pcszMsgFmt
     588 * @return  Most likely @hrc, see setErrorInternal.
     589 *
     590 * @sa      VirtualBoxBase::setError(HRESULT, const char *, ...)
     591 */
     592HRESULT VirtualBoxBase::setErrorBoth(HRESULT hrc, int vrc, const char *pcszMsgFmt, ...)
     593{
     594    va_list va;
     595    va_start(va, pcszMsgFmt);
     596    hrc = setErrorInternal(hrc,
     597                           this->getClassIID(),
     598                           this->getComponentName(),
     599                           Utf8Str(pcszMsgFmt, va),
     600                           false /* aWarning */,
     601                           true /* aLogIt */,
     602                           vrc /* aResultDetail */);
     603    va_end(va);
     604    return hrc;
     605}
     606
     607/**
    506608 * Like setError(), but sets the "warning" bit in the call to setErrorInternal().
    507609 * @param aResultCode
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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