Changeset 2850 for box/trunk/lib


Ignore:
Timestamp:
12/01/2011 00:14:06 (17 months ago)
Author:
chris
Message:

Improve error messages on failure to open a RaidFile? for reading.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/raidfile/RaidFileRead.cpp

    r2465 r2850  
    10871087                                stripe2errno = errno; 
    10881088                        } 
    1089                         if(stripe1errno != 0 || stripe2errno != 0) 
    1090                         { 
    1091                                 THROW_EXCEPTION(RaidFileException, ErrorOpeningFileForRead) 
     1089 
     1090                        if(stripe1errno != 0) 
     1091                        { 
     1092                                THROW_SYS_FILE_ERRNO("Failed to open RaidFile", 
     1093                                        stripe1Filename, stripe1errno, 
     1094                                        RaidFileException, ErrorOpeningFileForRead); 
     1095                        } 
     1096 
     1097                        if(stripe2errno != 0) 
     1098                        { 
     1099                                THROW_SYS_FILE_ERRNO("Failed to open RaidFile", 
     1100                                        stripe2Filename, stripe2errno, 
     1101                                        RaidFileException, ErrorOpeningFileForRead); 
    10921102                        } 
    10931103                         
     
    11081118                         
    11091119                        // Handle errors 
    1110                         if(stripe1errno != 0 || stripe2errno != 0) 
    1111                         { 
    1112                                 THROW_EXCEPTION(RaidFileException, OSError) 
    1113                         } 
    1114                          
     1120                        if(stripe1errno != 0) 
     1121                        { 
     1122                                THROW_SYS_FILE_ERRNO("Failed to stat RaidFile", 
     1123                                        stripe1Filename, stripe1errno, 
     1124                                        RaidFileException, OSError); 
     1125                        } 
     1126 
     1127                        if(stripe2errno != 0) 
     1128                        { 
     1129                                THROW_SYS_FILE_ERRNO("Failed to stat RaidFile", 
     1130                                        stripe2Filename, stripe2errno, 
     1131                                        RaidFileException, OSError); 
     1132                        } 
     1133         
    11151134                        // Make a nice object to represent this file 
    11161135                        return std::auto_ptr<RaidFileRead>(new RaidFileRead_Raid(SetNumber, Filename, stripe1, stripe2, -1, length, rdiscSet.GetBlockSize(), false /* actually we don't know */)); 
     
    12391258                                if(::lseek(parity, -8 /*(0 - sizeof(FileSizeType))*/, SEEK_END) == -1) 
    12401259                                { 
    1241                                         THROW_EXCEPTION(RaidFileException, OSError) 
     1260                                        THROW_SYS_FILE_ERROR("Failed to seek " 
     1261                                                "in parity RaidFile", 
     1262                                                parityFilename,  
     1263                                                RaidFileException, OSError); 
    12421264                                } 
    12431265                                // Read it in 
    12441266                                if(::read(parity, &parityLastData, sizeof(parityLastData)) != sizeof(parityLastData)) 
    12451267                                { 
    1246                                         THROW_EXCEPTION(RaidFileException, OSError) 
    1247                                 } 
     1268                                        THROW_SYS_FILE_ERROR("Failed to read " 
     1269                                                "parity RaidFile", 
     1270                                                parityFilename,  
     1271                                                RaidFileException, OSError); 
     1272                                } 
     1273 
    12481274                                // Set back to beginning of file 
    12491275                                if(::lseek(parity, 0, SEEK_SET) == -1) 
    12501276                                { 
    1251                                         THROW_EXCEPTION(RaidFileException, OSError) 
     1277                                        THROW_SYS_FILE_ERROR("Failed to seek " 
     1278                                                "in parity RaidFile", 
     1279                                                parityFilename,  
     1280                                                RaidFileException, OSError); 
    12521281                                } 
    12531282                        } 
     
    12721301                                        if(::fstat(stripe1, &st) != 0) 
    12731302                                        { 
    1274                                                 THROW_EXCEPTION(RaidFileException, OSError) 
     1303                                                THROW_SYS_FILE_ERROR("Failed to " 
     1304                                                        "stat RaidFile stripe 1", 
     1305                                                        stripe1Filename, 
     1306                                                        RaidFileException, OSError); 
    12751307                                        } 
    12761308                                        pos_type stripe1Size = st.st_size; 
     
    13061338                                                        if(::lseek(stripe1, 0 - btr, SEEK_END) == -1) 
    13071339                                                        { 
    1308                                                                 THROW_EXCEPTION(RaidFileException, OSError) 
     1340                                                                THROW_SYS_FILE_ERROR("Failed to " 
     1341                                                                        "seek in RaidFile stripe 1", 
     1342                                                                        stripe1Filename, 
     1343                                                                        RaidFileException, OSError); 
    13091344                                                        } 
    13101345                                                        // Read it in 
    13111346                                                        if(::read(stripe1, &stripe1LastData, btr) != btr) 
    13121347                                                        { 
    1313                                                                 THROW_EXCEPTION(RaidFileException, OSError) 
     1348                                                                THROW_SYS_FILE_ERROR("Failed to " 
     1349                                                                        "read RaidFile stripe 1", 
     1350                                                                        stripe1Filename, 
     1351                                                                        RaidFileException, OSError); 
    13141352                                                        } 
    13151353                                                        // Set back to beginning of file 
    13161354                                                        if(::lseek(stripe1, 0, SEEK_SET) == -1) 
    13171355                                                        { 
    1318                                                                 THROW_EXCEPTION(RaidFileException, OSError) 
     1356                                                                THROW_SYS_FILE_ERROR("Failed to " 
     1357                                                                        "seek in RaidFile stripe 1", 
     1358                                                                        stripe1Filename, 
     1359                                                                        RaidFileException, OSError); 
    13191360                                                        } 
    13201361                                                } 
     
    13381379                                        if(::fstat(stripe2, &st) != 0) 
    13391380                                        { 
    1340                                                 THROW_EXCEPTION(RaidFileException, OSError) 
     1381                                                THROW_SYS_FILE_ERROR("Failed to " 
     1382                                                        "stat RaidFile stripe 2", 
     1383                                                        stripe2Filename, 
     1384                                                        RaidFileException, OSError); 
    13411385                                        } 
    13421386                                        pos_type stripe2Size = st.st_size; 
     
    14071451        } 
    14081452         
    1409         THROW_EXCEPTION(RaidFileException, FileIsDamagedNotRecoverable) 
     1453        THROW_FILE_ERROR("Failed to recover RaidFile", Filename, 
     1454                RaidFileException, FileIsDamagedNotRecoverable); 
    14101455         
    14111456        // Avoid compiler warning -- it'll never get here... 
Note: See TracChangeset for help on using the changeset viewer.