Ticket #144: formaterror.patch

File formaterror.patch, 8.3 KB (added by Richard Boulton, 18 years ago)

Patch which implements DatabaseFormatError

  • include/xapian/database.h

     
    4949 *
    5050 *  @exception DatabaseOpeningError may be thrown if the database cannot
    5151 *  be opened (for example, a required file cannot be found).
     52 *
     53 *  @exception DatabaseFormatError may be thrown if the database is in an
     54 *  unsupported format (for example, created by a newer version of Xapian
     55 *  which uses an incompatible format).
    5256 */
    5357class XAPIAN_VISIBILITY_DEFAULT Database {
    5458    public:
  • exception_data.pm

     
    128128/** DatabaseOpeningError indicates failure to open a database. */
    129129DOC
    130130
     131errorclass('DatabaseFormatError', 'DatabaseOpeningError', <<'DOC');
     132/** DatabaseFormatError indicates that a database is in an unknown format.
     133 *
     134 *  From time to time, new versions of Xapian will require the database format
     135 *  to be changed, to allow new information to be stored or new optimisations
     136 *  to be performed.  Backwards compatibility will sometimes be maintained, so
     137 *  that new versions of Xapian can open old databases, but in some cases
     138 *  Xapian will be unable to open a database because it is in too old (or new)
     139 *  a format.  This can be resolved either be upgrading or downgrading the
     140 *  version of Xapian in use, or by rebuilding the database from scratch with
     141 *  the current version of Xapian.
     142 */
     143DOC
     144
    131145errorclass('DocNotFoundError', 'RuntimeError', <<'DOC');
    132146/** Indicates an attempt to access a document not present in the database. */
    133147DOC
  • backends/quartz/quartz_metafile.cc

     
    8080    unsigned int version;
    8181    version = decode_version(data.substr(metafile_magic.length(), 4));
    8282    if (version != metafile_version) {
    83         throw Xapian::DatabaseOpeningError("Unknown Quartz metafile version " +
     83        throw Xapian::DatabaseFormatError("Unknown Quartz metafile version " +
    8484                             om_tostring(version) + " in " +
    8585                             filename);
    8686    }
  • backends/quartz/quartz_database.h

     
    183183         *  @exception Xapian::DatabaseCorruptError is thrown if there is no
    184184         *             consistent revision available.
    185185         *
    186          *  @exception Xapian::DatabaseOpeningError thrown if database can't be opened.
     186         *  @exception Xapian::DatabaseOpeningError thrown if database can't be
     187         *             opened.
    187188         *
     189         *  @exception Xapian::DatabaseFormatError thrown if database is in an
     190         *             unsupported format.  This implies that the database was
     191         *             created by an older or newer version of Xapian.
     192         *
    188193         *  @param dbdir directory holding quartz tables
    189194         *
    190195         *  @param block_size Block size, in bytes, to use when creating
     
    282287    public:
    283288        /** Create and open a writable quartz database.
    284289         *
    285          *  @exception Xapian::DatabaseOpeningError thrown if database can't be opened.
     290         *  @exception Xapian::DatabaseOpeningError thrown if database can't be
     291         *             opened.
    286292         *
     293         *  @exception Xapian::DatabaseFormatError thrown if database is in an
     294         *             unsupported format.  This implies that the database was
     295         *             created by an older or newer version of Xapian.
     296         *
    287297         *  @param dir directory holding quartz tables
    288298         */
    289299        QuartzWritableDatabase(const string &dir, int action, int block_size);
  • backends/quartz/quartz_metafile.h

     
    4545        /** Open the meta-file.
    4646         *
    4747         *  @except     Xapian::DatabaseOpeningError if the meta-file was not
    48          *              opened successfully or is compatible with this version
    49          *              of the library.
     48         *              opened successfully or is not compatible with this
     49         *              version of the library.
    5050         */
    5151        void open();
    5252
  • backends/quartz/quartz_database.cc

     
    9696        if (!dbexists) {
    9797            // Catch pre-0.6 Xapian databases and give a better error
    9898            if (file_exists(db_dir + "/attribute_DB"))
    99                 throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
     99                throw Xapian::DatabaseFormatError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
    100100            throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it does not exist");
    101101        }
    102102        // Can still allow searches even if recovery is needed
     
    107107            if (action == Xapian::DB_OPEN) {
    108108                // Catch pre-0.6 Xapian databases and give a better error
    109109                if (file_exists(db_dir + "/attribute_DB"))
    110                     throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
     110                    throw Xapian::DatabaseFormatError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
    111111                throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it does not exist");
    112112            }
    113113
  • backends/flint/flint_database.h

     
    176176         *  @exception Xapian::DatabaseCorruptError is thrown if there is no
    177177         *             consistent revision available.
    178178         *
    179          *  @exception Xapian::DatabaseOpeningError thrown if database can't be opened.
     179         *  @exception Xapian::DatabaseOpeningError thrown if database can't
     180         *             be opened.
    180181         *
     182         *  @exception Xapian::DatabaseFormatError thrown if database is in an
     183         *             unsupported format.  This implies that the database was
     184         *             created by an older or newer version of Xapian.
     185         *
    181186         *  @param dbdir directory holding flint tables
    182187         *
    183188         *  @param block_size Block size, in bytes, to use when creating
     
    275280    public:
    276281        /** Create and open a writable flint database.
    277282         *
    278          *  @exception Xapian::DatabaseOpeningError thrown if database can't be opened.
     283         *  @exception Xapian::DatabaseOpeningError thrown if database can't
     284         *             be opened.
    279285         *
     286         *  @exception Xapian::DatabaseFormatError thrown if database is in an
     287         *             unsupported format.  This implies that the database was
     288         *             created by an older or newer version of Xapian.
     289         *
    280290         *  @param dir directory holding flint tables
    281291         */
    282292        FlintWritableDatabase(const string &dir, int action, int block_size);
  • backends/flint/flint_version.cc

     
    126126        msg += " is version ";
    127127        msg += om_tostring(version);
    128128        msg += " but I only understand "STRINGIZE(FLINT_VERSION);
    129         throw Xapian::DatabaseOpeningError(msg);
     129        throw Xapian::DatabaseFormatError(msg);
    130130    }
    131131}
  • backends/flint/flint_database.cc

     
    8282        if (!dbexists) {
    8383            // Catch pre-0.6 Xapian databases and give a better error
    8484            if (file_exists(db_dir + "/attribute_DB"))
    85                 throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
     85                throw Xapian::DatabaseFormatError("Cannot open database at `" + db_dir + "' - it was created by a pre-0.6 version of Xapian");
    8686            throw Xapian::DatabaseOpeningError("Cannot open database at `" + db_dir + "' - it does not exist");
    8787        }
    8888        // Can still allow searches even if recovery is needed