Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

HRESULT MediumBase::setStateError (  )  [protected]

Sets the extended error info according to the current media state.

Note:
Must be called from under this object's write or read lock.

Definition at line 852 of file MediumImpl.cpp.

References AssertFailed, AssertMsg, com::SupportErrorInfoBase::setError(), and VirtualBoxSupportTranslation< MediumBase >::tr().

Referenced by attachTo(), HardDisk::CreateBaseStorage(), HardDisk::deleteStorage(), LockRead(), LockWrite(), and HardDisk::prepareDiscard().

{
    HRESULT rc = E_FAIL;

    switch (m.state)
    {
        case MediaState_NotCreated:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Storage for the medium '%ls' is not created"),
                m.locationFull.raw());
            break;
        }
        case MediaState_Created:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Storage for the medium '%ls' is already created"),
                m.locationFull.raw());
            break;
        }
        case MediaState_LockedRead:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Medium '%ls' is locked for reading by another task"),
                m.locationFull.raw());
            break;
        }
        case MediaState_LockedWrite:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Medium '%ls' is locked for writing by another task"),
                m.locationFull.raw());
            break;
        }
        case MediaState_Inaccessible:
        {
            AssertMsg (!m.lastAccessError.isEmpty(),
                       ("There must always be a reason for Inaccessible"));

            /* be in sync with Console::powerUpThread() */
            if (!m.lastAccessError.isEmpty())
                rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                    tr ("Medium '%ls' is not accessible. %ls"),
                    m.locationFull.raw(), m.lastAccessError.raw());
            else
                rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                    tr ("Medium '%ls' is not accessible"),
                    m.locationFull.raw());
            break;
        }
        case MediaState_Creating:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Storage for the medium '%ls' is being created"),
                m.locationFull.raw(), m.lastAccessError.raw());
            break;
        }
        case MediaState_Deleting:
        {
            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
                tr ("Storage for the medium '%ls' is being deleted"),
                m.locationFull.raw(), m.lastAccessError.raw());
            break;
        }
        default:
        {
            AssertFailed();
            break;
        }
    }

    return rc;
}


Generated by  Doxygen 1.6.0   Back to index