VirtualBox

Changeset 31239 in vbox


Ignore:
Timestamp:
Jul 30, 2010 11:58:45 AM (15 years ago)
Author:
vboxsync
Message:

Main: use VBox error codes in IMedium

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r31236 r31239  
    90079007    /* enumerate new attachments */
    90089008    for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin();
    9009             it != mMediaData->mAttachments.end();
    9010             ++it)
     9009         it != mMediaData->mAttachments.end();
     9010         ++it)
    90119011    {
    90129012        MediumAttachment *pAttach = *it;
  • trunk/src/VBox/Main/MediumImpl.cpp

    r31236 r31239  
    14311431    /* cannot change the type of a differencing medium */
    14321432    if (m->pParent)
    1433         return setError(E_FAIL,
     1433        return setError(VBOX_E_INVALID_OBJECT_STATE,
    14341434                        tr("Cannot change the type of medium '%s' because it is a differencing medium"),
    14351435                        m->strLocationFull.raw());
     
    14371437    /* cannot change the type of a medium being in use by more than one VM */
    14381438    if (m->backRefs.size() > 1)
    1439         return setError(E_FAIL,
     1439        return setError(VBOX_E_INVALID_OBJECT_STATE,
    14401440                        tr("Cannot change the type of medium '%s' because it is attached to %d virtual machines"),
    14411441                        m->strLocationFull.raw(), m->backRefs.size());
     
    14561456            /* cannot change to writethrough or shareable if there are children */
    14571457            if (getChildren().size() != 0)
    1458                 return setError(E_FAIL,
     1458                return setError(VBOX_E_OBJECT_IN_USE,
    14591459                                tr("Cannot change type for medium '%s' since it has %d child media"),
    14601460                                m->strLocationFull.raw(), getChildren().size());
     
    14631463                MediumVariant_T variant = getVariant();
    14641464                if (!(variant & MediumVariant_Fixed))
    1465                     return setError(E_FAIL,
     1465                    return setError(VBOX_E_INVALID_OBJECT_STATE,
    14661466                                    tr("Cannot change type for medium '%s' to 'Shareable' since it is a dynamic medium storage unit"),
    14671467                                    m->strLocationFull.raw());
    1468 
    14691468            }
    14701469            break;
     
    21952194
    21962195    if (m->type == MediumType_Writethrough)
    2197         return setError(E_FAIL,
     2196        return setError(VBOX_E_INVALID_OBJECT_STATE,
    21982197                        tr("Medium type of '%s' is Writethrough"),
    21992198                        m->strLocationFull.raw());
    22002199    else if (m->type == MediumType_Shareable)
    2201         return setError(E_FAIL,
     2200        return setError(VBOX_E_INVALID_OBJECT_STATE,
    22022201                        tr("Medium type of '%s' is Shareable"),
    22032202                        m->strLocationFull.raw());
     
    26812680
    26822681    if (m->numCreateDiffTasks > 0)
    2683         return setError(E_FAIL,
     2682        return setError(VBOX_E_OBJECT_IN_USE,
    26842683                        tr("Cannot attach medium '%s' {%RTuuid}: %u differencing child media are being created"),
    26852684                        m->strLocationFull.raw(),
     
    27242723            dumpBackRefs();
    27252724#endif
    2726             return setError(E_FAIL,
     2725            return setError(VBOX_E_OBJECT_IN_USE,
    27272726                            tr("Cannot attach medium '%s' {%RTuuid} from snapshot '%RTuuid': medium is already in use by this snapshot!"),
    27282727                            m->strLocationFull.raw(),
     
    31073106        int vrc = m->pVirtualBox->calculateFullPath(location, location);
    31083107        if (RT_FAILURE(vrc))
    3109             return setError(E_FAIL,
     3108            return setError(VBOX_E_FILE_ERROR,
    31103109                            tr("Invalid medium storage file location '%s' (%Rrc)"),
    31113110                            location.raw(),
     
    43814380
    43824381                AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    4383                 throw setError(E_FAIL,
     4382                throw setError(VBOX_E_INVALID_OBJECT_STATE,
    43844383                               tr("Media '%s' and '%s' are unrelated"),
    43854384                               m->strLocationFull.raw(), tgtLoc.raw());
     
    44274426            if (getChildren().size() > 1)
    44284427            {
    4429                 throw setError(E_FAIL,
     4428                throw setError(VBOX_E_INVALID_OBJECT_STATE,
    44304429                               tr("Medium '%s' involved in the merge operation has more than one child medium (%d)"),
    44314430                               m->strLocationFull.raw(), getChildren().size());
     
    44414440                    || (   (!aSnapshotId || !aSnapshotId->isEmpty())
    44424441                        && *getFirstMachineBackrefSnapshotId() != *aSnapshotId)))
    4443                 throw setError(E_FAIL,
     4442                throw setError(VBOX_E_OBJECT_IN_USE,
    44444443                               tr("Medium '%s' is attached to %d virtual machines"),
    44454444                               m->strLocationFull.raw(), m->backRefs.size());
    44464445            if (m->type == MediumType_Immutable)
    4447                 throw setError(E_FAIL,
     4446                throw setError(VBOX_E_INVALID_OBJECT_STATE,
    44484447                               tr("Medium '%s' is immutable"),
    44494448                               m->strLocationFull.raw());
     
    44544453            if (pTarget->getChildren().size() > 1)
    44554454            {
    4456                 throw setError(E_FAIL,
     4455                throw setError(VBOX_E_OBJECT_IN_USE,
    44574456                               tr("Medium '%s' involved in the merge operation has more than one child medium (%d)"),
    44584457                               pTarget->m->strLocationFull.raw(),
     
    44604459            }
    44614460            if (pTarget->m->type == MediumType_Immutable)
    4462                 throw setError(E_FAIL,
     4461                throw setError(VBOX_E_INVALID_OBJECT_STATE,
    44634462                               tr("Medium '%s' is immutable"),
    44644463                               pTarget->m->strLocationFull.raw());
     
    44734472            if (pLast->getChildren().size() > 1)
    44744473            {
    4475                 throw setError(E_FAIL,
     4474                throw setError(VBOX_E_OBJECT_IN_USE,
    44764475                               tr("Medium '%s' involved in the merge operation has more than one child medium (%d)"),
    44774476                               pLast->m->strLocationFull.raw(),
     
    44794478            }
    44804479            if (pLast->m->backRefs.size() != 0)
    4481                 throw setError(E_FAIL,
     4480                throw setError(VBOX_E_OBJECT_IN_USE,
    44824481                               tr("Medium '%s' is attached to %d virtual machines"),
    44834482                               pLast->m->strLocationFull.raw(),
     
    48734872
    48744873    if (getChildren().size() != 0)
    4875         return setError(E_FAIL,
     4874        return setError(VBOX_E_OBJECT_IN_USE,
    48764875                        tr("Cannot close medium '%s' because it has %d child media"),
    48774876                        m->strLocationFull.raw(), getChildren().size());
     
    53825381                               task.mVDOperationIfaces);
    53835382            if (RT_FAILURE(vrc))
    5384                 throw setError(E_FAIL,
    5385                             tr("Could not create the medium storage unit '%s'%s"),
    5386                             location.raw(), vdError(vrc).raw());
     5383                throw setError(VBOX_E_FILE_ERROR,
     5384                               tr("Could not create the medium storage unit '%s'%s"),
     5385                               location.raw(), vdError(vrc).raw());
    53875386
    53885387            size = VDGetFileSize(hdd, 0);
     
    55285527                             pMedium->m->vdDiskIfaces);
    55295528                if (RT_FAILURE(vrc))
    5530                     throw setError(E_FAIL,
     5529                    throw setError(VBOX_E_FILE_ERROR,
    55315530                                   tr("Could not open the medium storage unit '%s'%s"),
    55325531                                   pMedium->m->strLocationFull.raw(),
     
    55505549                               task.mVDOperationIfaces);
    55515550            if (RT_FAILURE(vrc))
    5552                 throw setError(E_FAIL,
     5551                throw setError(VBOX_E_FILE_ERROR,
    55535552                                tr("Could not create the differencing medium storage unit '%s'%s"),
    55545553                                targetLocation.raw(), vdError(vrc).raw());
     
    57835782        catch (int aVRC)
    57845783        {
    5785             throw setError(E_FAIL,
     5784            throw setError(VBOX_E_FILE_ERROR,
    57865785                            tr("Could not merge the medium '%s' to '%s'%s"),
    57875786                            m->strLocationFull.raw(),
     
    60136012                             pMedium->m->vdDiskIfaces);
    60146013                if (RT_FAILURE(vrc))
    6015                     throw setError(E_FAIL,
    6016                                     tr("Could not open the medium storage unit '%s'%s"),
    6017                                     pMedium->m->strLocationFull.raw(),
    6018                                     vdError(vrc).raw());
     6014                    throw setError(VBOX_E_FILE_ERROR,
     6015                                   tr("Could not open the medium storage unit '%s'%s"),
     6016                                   pMedium->m->strLocationFull.raw(),
     6017                                   vdError(vrc).raw());
    60196018            }
    60206019
     
    60776076                                 pMedium->m->vdDiskIfaces);
    60786077                    if (RT_FAILURE(vrc))
    6079                         throw setError(E_FAIL,
     6078                        throw setError(VBOX_E_FILE_ERROR,
    60806079                                       tr("Could not open the medium storage unit '%s'%s"),
    60816080                                       pMedium->m->strLocationFull.raw(),
     
    60976096                             task.mVDOperationIfaces);
    60986097                if (RT_FAILURE(vrc))
    6099                     throw setError(E_FAIL,
    6100                                     tr("Could not create the clone medium '%s'%s"),
    6101                                     targetLocation.raw(), vdError(vrc).raw());
     6098                    throw setError(VBOX_E_FILE_ERROR,
     6099                                   tr("Could not create the clone medium '%s'%s"),
     6100                                   targetLocation.raw(), vdError(vrc).raw());
    61026101
    61036102                size = VDGetFileSize(targetHdd, VD_LAST_IMAGE);
     
    62326231
    62336232            if (RT_FAILURE(vrc))
    6234                 throw setError(E_FAIL,
    6235                                 tr("Could not delete the medium storage unit '%s'%s"),
    6236                                 location.raw(), vdError(vrc).raw());
     6233                throw setError(VBOX_E_FILE_ERROR,
     6234                               tr("Could not delete the medium storage unit '%s'%s"),
     6235                               location.raw(), vdError(vrc).raw());
    62376236
    62386237        }
     
    63276326                             pMedium->m->vdDiskIfaces);
    63286327                if (RT_FAILURE(vrc))
    6329                     throw setError(E_FAIL,
     6328                    throw setError(VBOX_E_FILE_ERROR,
    63306329                                   tr("Could not open the medium storage unit '%s'%s"),
    63316330                                   pMedium->m->strLocationFull.raw(),
     
    63406339            vrc = VDClose(hdd, true /* fDelete */);
    63416340            if (RT_FAILURE(vrc))
    6342                 throw setError(E_FAIL,
     6341                throw setError(VBOX_E_FILE_ERROR,
    63436342                               tr("Could not delete the medium storage unit '%s'%s"),
    63446343                               location.raw(), vdError(vrc).raw());
     
    63516350                         m->vdDiskIfaces);
    63526351            if (RT_FAILURE(vrc))
    6353                 throw setError(E_FAIL,
    6354                                 tr("Could not open the medium storage unit '%s'%s"),
    6355                                 parentLocation.raw(), vdError(vrc).raw());
     6352                throw setError(VBOX_E_FILE_ERROR,
     6353                               tr("Could not open the medium storage unit '%s'%s"),
     6354                               parentLocation.raw(), vdError(vrc).raw());
    63566355
    63576356            vrc = VDCreateDiff(hdd,
     
    63676366                               task.mVDOperationIfaces);
    63686367            if (RT_FAILURE(vrc))
    6369                 throw setError(E_FAIL,
    6370                                 tr("Could not create the differencing medium storage unit '%s'%s"),
    6371                                 location.raw(), vdError(vrc).raw());
     6368                throw setError(VBOX_E_FILE_ERROR,
     6369                               tr("Could not create the differencing medium storage unit '%s'%s"),
     6370                               location.raw(), vdError(vrc).raw());
    63726371
    63736372            size = VDGetFileSize(hdd, VD_LAST_IMAGE);
     
    64576456                             pMedium->m->vdDiskIfaces);
    64586457                if (RT_FAILURE(vrc))
    6459                     throw setError(E_FAIL,
     6458                    throw setError(VBOX_E_FILE_ERROR,
    64606459                                   tr("Could not open the medium storage unit '%s'%s"),
    64616460                                   pMedium->m->strLocationFull.raw(),
     
    64826481                                   location.raw());
    64836482                else
    6484                     throw setError(E_FAIL,
     6483                    throw setError(VBOX_E_FILE_ERROR,
    64856484                                   tr("Could not compact medium '%s'%s"),
    64866485                                   location.raw(),
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