Changeset 2968


Ignore:
Timestamp:
16/06/2011 16:45:26 (11 months ago)
Author:
chris
Message:

Improve error logging for store info and refcount database errors.

Location:
box/trunk/lib/backupstore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/backupstore/BackupStoreInfo.cpp

    r2903 r2968  
    142142// 
    143143// -------------------------------------------------------------------------- 
    144 std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const std::string &rRootDir, int DiscSet, bool ReadOnly, int64_t *pRevisionID) 
     144std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, 
     145        const std::string &rRootDir, int DiscSet, bool ReadOnly, 
     146        int64_t *pRevisionID) 
    145147{ 
    146148        // Generate the filename 
     
    154156        if(!rf->ReadFullBuffer(&magic, sizeof(magic), 0)) 
    155157        { 
    156                 THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo); 
     158                THROW_FILE_ERROR("Failed to read store info file: " 
     159                        "short read of magic number", fn, 
     160                        BackupStoreException, CouldNotLoadStoreInfo); 
    157161        } 
    158162 
     
    169173        else 
    170174        { 
    171                 THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad) 
     175                THROW_FILE_ERROR("Failed to read store info file: " 
     176                        "unknown magic " << BOX_FORMAT_HEX32(ntohl(magic)), 
     177                        fn, BackupStoreException, BadStoreInfoOnLoad); 
    172178        } 
    173179 
     
    224230                if (FileAccountID != AccountID) 
    225231                { 
    226                         THROW_FILE_ERROR("Found wrong account ID in store info", 
     232                        THROW_FILE_ERROR("Found wrong account ID in store " 
     233                                "info: " << BOX_FORMAT_HEX32(FileAccountID), 
    227234                                fn, BackupStoreException, BadStoreInfoOnLoad); 
    228235                } 
  • box/trunk/lib/backupstore/BackupStoreRefCountDatabase.cpp

    r2932 r2968  
    9292        if (FileExists(Filename) && !AllowOverwrite) 
    9393        { 
    94                 BOX_ERROR("Attempted to overwrite refcount database file: " << 
    95                         Filename); 
    96                 THROW_EXCEPTION(RaidFileException, CannotOverwriteExistingFile); 
     94                THROW_FILE_ERROR("Failed to overwrite refcount database: " 
     95                        "not allowed here", Filename, RaidFileException, 
     96                        CannotOverwriteExistingFile); 
    9797        } 
    9898 
     
    135135        if(!dbfile->ReadFullBuffer(&hdr, sizeof(hdr), 0 /* not interested in bytes read if this fails */)) 
    136136        { 
    137                 THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo) 
     137                THROW_FILE_ERROR("Failed to read refcount database: " 
     138                        "short read", filename, BackupStoreException, 
     139                        CouldNotLoadStoreInfo); 
    138140        } 
    139141         
     
    142144                (int32_t)ntohl(hdr.mAccountID) != rAccount.GetID()) 
    143145        { 
    144                 THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad) 
     146                THROW_FILE_ERROR("Failed to read refcount database: " 
     147                        "bad magic number", filename, BackupStoreException, 
     148                        BadStoreInfoOnLoad); 
    145149        } 
    146150         
     
    256260        if (GetSize() < offset + GetEntrySize()) 
    257261        { 
    258                 BOX_ERROR("attempted read of unknown refcount for object " << 
    259                         BOX_FORMAT_OBJECTID(ObjectID)); 
    260                 THROW_EXCEPTION(BackupStoreException, 
    261                         UnknownObjectRefCountRequested); 
     262                THROW_FILE_ERROR("Failed to read refcount database: " 
     263                        "attempted read of unknown refcount for object " << 
     264                        BOX_FORMAT_OBJECTID(ObjectID), mFilename, 
     265                        BackupStoreException, UnknownObjectRefCountRequested); 
    262266        } 
    263267 
     
    268272                sizeof(refcount)) 
    269273        { 
    270                 BOX_LOG_SYS_ERROR("short read on refcount database: " << 
    271                         mFilename); 
    272                 THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo); 
     274                THROW_FILE_ERROR("Failed to read refcount database: " 
     275                        "short read at offset " << offset, mFilename, 
     276                        BackupStoreException, CouldNotLoadStoreInfo); 
    273277        } 
    274278 
Note: See TracChangeset for help on using the changeset viewer.