[ci] Try to get .gitignore check to work
[xapian.git] / xapian-core / exception_data.pm
blob56f5521b9432233a2031bc54e4419120587297ee
1 # exception_data.pm: details of the exception hierarchy used by Xapian.
2 package exception_data;
3 $copyright = <<'EOF';
4 /* Copyright (C) 2003,2004,2006,2007,2008,2009,2011,2015 Olly Betts
5 * Copyright (C) 2007 Richard Boulton
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 EOF
23 use Exporter;
24 @ISA = qw(Exporter);
25 @EXPORT = qw(
26 $copyright $generated_warning @baseclasses @classes %subclasses %classcode
29 $generated_warning =
30 "/* Warning: This file is generated by $0 - do not modify directly! */\n";
32 @baseclasses = ();
33 @classes = ();
34 %subclasses = ();
35 %classcode = ();
37 sub errorbaseclass {
38 push @baseclasses, join("\t", @_);
39 push @{$subclasses{$_[1]}}, $_[0];
42 sub errorclass {
43 my $typecode = shift;
44 my ($class, $parent) = @_;
45 push @classes, join("\t", @_);
46 push @{$subclasses{$parent}}, $class;
47 $classcode{$class} = $typecode;
50 errorbaseclass('LogicError', 'Error', <<'DOC');
51 /** The base class for exceptions indicating errors in the program logic.
53 * A subclass of LogicError will be thrown if Xapian detects a violation
54 * of a class invariant or a logical precondition or postcondition, etc.
56 DOC
58 errorclass(0, 'AssertionError', 'LogicError', <<'DOC');
59 /** AssertionError is thrown if a logical assertion inside Xapian fails.
61 * In a debug build of Xapian, a failed assertion in the core library code
62 * will cause AssertionError to be thrown.
64 * This represents a bug in Xapian (either an invariant, precondition, etc
65 * has been violated, or the assertion is incorrect!)
67 DOC
69 errorclass(1, 'InvalidArgumentError', 'LogicError', <<'DOC');
70 /** InvalidArgumentError indicates an invalid parameter value was passed to the API.
72 DOC
74 errorclass(2, 'InvalidOperationError', 'LogicError', <<'DOC');
75 /** InvalidOperationError indicates the API was used in an invalid way.
77 DOC
79 errorclass(3, 'UnimplementedError', 'LogicError', <<'DOC');
80 /** UnimplementedError indicates an attempt to use an unimplemented feature. */
81 DOC
83 # RuntimeError and subclasses:
85 errorbaseclass('RuntimeError', 'Error', <<'DOC');
86 /** The base class for exceptions indicating errors only detectable at runtime.
88 * A subclass of RuntimeError will be thrown if Xapian detects an error
89 * which is exception derived from RuntimeError is thrown when an
90 * error is caused by problems with the data or environment rather
91 * than a programming mistake.
93 DOC
95 errorclass(4, 'DatabaseError', 'RuntimeError', <<'DOC');
96 /** DatabaseError indicates some sort of database related error. */
97 DOC
99 errorclass(5, 'DatabaseCorruptError', 'DatabaseError', <<'DOC');
100 /** DatabaseCorruptError indicates database corruption was detected. */
103 errorclass(6, 'DatabaseCreateError', 'DatabaseError', <<'DOC');
104 /** DatabaseCreateError indicates a failure to create a database. */
107 errorclass(7, 'DatabaseLockError', 'DatabaseError', <<'DOC');
108 /** DatabaseLockError indicates failure to lock a database. */
111 errorclass(8, 'DatabaseModifiedError', 'DatabaseError', <<'DOC');
112 /** DatabaseModifiedError indicates a database was modified.
114 * To recover after catching this error, you need to call
115 * Xapian::Database::reopen() on the Database and repeat the operation
116 * which failed.
120 errorclass(9, 'DatabaseOpeningError', 'DatabaseError', <<'DOC');
121 /** DatabaseOpeningError indicates failure to open a database. */
124 errorclass(10, 'DatabaseVersionError', 'DatabaseOpeningError', <<'DOC');
125 /** DatabaseVersionError indicates that a database is in an unsupported format.
127 * From time to time, new versions of Xapian will require the database format
128 * to be changed, to allow new information to be stored or new optimisations
129 * to be performed. Backwards compatibility will sometimes be maintained, so
130 * that new versions of Xapian can open old databases, but in some cases
131 * Xapian will be unable to open a database because it is in too old (or new)
132 * a format. This can be resolved either be upgrading or downgrading the
133 * version of Xapian in use, or by rebuilding the database from scratch with
134 * the current version of Xapian.
138 errorclass(11, 'DocNotFoundError', 'RuntimeError', <<'DOC');
139 /** Indicates an attempt to access a document not present in the database. */
142 errorclass(12, 'FeatureUnavailableError', 'RuntimeError', <<'DOC');
143 /** Indicates an attempt to use a feature which is unavailable.
145 * Typically a feature is unavailable because it wasn't compiled in, or
146 * because it requires other software or facilities which aren't available.
150 errorclass(13, 'InternalError', 'RuntimeError', <<'DOC');
151 /** InternalError indicates a runtime problem of some sort. */
154 errorclass(14, 'NetworkError', 'RuntimeError', <<'DOC');
155 /** Indicates a problem communicating with a remote database. */
158 errorclass(15, 'NetworkTimeoutError', 'NetworkError', <<'DOC');
159 /** Indicates a timeout expired while communicating with a remote database. */
162 errorclass(16, 'QueryParserError', 'RuntimeError', <<'DOC');
163 /** Indicates a query string can't be parsed. */
166 errorclass(17, 'SerialisationError', 'RuntimeError', <<'DOC');
167 /** Indicates an error in the std::string serialisation of an object. */
170 errorclass(18, 'RangeError', 'RuntimeError', <<'DOC');
171 /** RangeError indicates an attempt to access outside the bounds of a container.
175 errorclass(19, 'WildcardError', 'RuntimeError', <<'DOC');
176 /** WildcardError indicates an error expanding a wildcarded query.
180 sub for_each_nothrow {
181 my $func = shift @_;
182 my $class = '';
183 foreach my $header ('include/xapian.h', <include/xapian/*.h>) {
184 local $/ = undef;
185 open H, '<', $header or die $!;
186 my $header_text = <H>;
187 # Strip comments, which might contain text describing XAPIAN_NOTHROW().
188 $header_text =~ s!/(?:/[^\n]*|\*.*?\*/)! !gs;
189 for (split /\n/, $header_text) {
190 if (/^\s*class\s+XAPIAN_VISIBILITY_DEFAULT\s+(\w+)/) {
191 $class = "$1::";
192 next;
194 if (/^[^#]*\bXAPIAN_NOTHROW\((.*)\)/) {
195 &$func("Xapian::$class$1");
198 close H;