Lucene++ - a full-featured, c++ search engine
API Documentation

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LuceneException.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef LUCENEEXCEPTION_H
8 #define LUCENEEXCEPTION_H
9
10 #include "Lucene.h"
11
12 namespace Lucene
13 {
15 class LPPAPI LuceneException : public std::exception
16 {
17 public:
18 enum ExceptionType
19 {
20 Null,
21 AlreadyClosed,
22 Compression,
23 CorruptIndex,
24 FieldReader,
25 FileNotFound,
26 IllegalArgument,
27 IllegalState,
28 IndexOutOfBounds,
29 IO,
30 LockObtainFailed,
31 LockReleaseFailed,
32 Lookahead,
33 MergeAborted,
34 Merge,
35 NoSuchDirectory,
36 NullPointer,
37 NumberFormat,
38 OutOfMemory,
39 Parse,
40 QueryParser,
41 Runtime,
42 StaleReader,
43 StopFillCache,
44 Temporary,
45 TimeExceeded,
46 TooManyClauses,
47 UnsupportedOperation
48 };
49
50 LuceneException(const String& error = EmptyString, LuceneException::ExceptionType type = Null) throw();
51 ~LuceneException() throw();
52
53 protected:
54 ExceptionType type;
55 String error;
56
57 public:
58 ExceptionType getType() const;
59 String getError() const;
60 bool isNull() const;
61 void throwException();
62 };
63
64 template <class ParentException, LuceneException::ExceptionType Type>
65 class ExceptionTemplate : public ParentException
66 {
67 public:
68 ExceptionTemplate(const String& error = EmptyString, LuceneException::ExceptionType type = Type) : ParentException(error, type)
69 {
70 }
71 };
72
73 typedef ExceptionTemplate<LuceneException, LuceneException::Runtime> RuntimeException;
74 typedef ExceptionTemplate<LuceneException, LuceneException::OutOfMemory> OutOfMemoryError;
75 typedef ExceptionTemplate<LuceneException, LuceneException::Temporary> TemporaryException;
76 typedef ExceptionTemplate<RuntimeException, LuceneException::IllegalState> IllegalStateException;
77 typedef ExceptionTemplate<RuntimeException, LuceneException::IllegalArgument> IllegalArgumentException;
78 typedef ExceptionTemplate<RuntimeException, LuceneException::IndexOutOfBounds> IndexOutOfBoundsException;
79 typedef ExceptionTemplate<RuntimeException, LuceneException::NullPointer> NullPointerException;
80 typedef ExceptionTemplate<RuntimeException, LuceneException::FieldReader> FieldReaderException;
81 typedef ExceptionTemplate<RuntimeException, LuceneException::Merge> MergeException;
82 typedef ExceptionTemplate<RuntimeException, LuceneException::StopFillCache> StopFillCacheException;
83 typedef ExceptionTemplate<RuntimeException, LuceneException::TimeExceeded> TimeExceededException;
84 typedef ExceptionTemplate<RuntimeException, LuceneException::TooManyClauses> TooManyClausesException;
85 typedef ExceptionTemplate<RuntimeException, LuceneException::UnsupportedOperation> UnsupportedOperationException;
86 typedef ExceptionTemplate<IllegalArgumentException, LuceneException::NumberFormat> NumberFormatException;
87 typedef ExceptionTemplate<IllegalStateException, LuceneException::AlreadyClosed> AlreadyClosedException;
88 typedef ExceptionTemplate<LuceneException, LuceneException::IO> IOException;
89 typedef ExceptionTemplate<IOException, LuceneException::CorruptIndex> CorruptIndexException;
90 typedef ExceptionTemplate<IOException, LuceneException::FileNotFound> FileNotFoundException;
91 typedef ExceptionTemplate<IOException, LuceneException::LockObtainFailed> LockObtainFailedException;
92 typedef ExceptionTemplate<IOException, LuceneException::LockReleaseFailed> LockReleaseFailedException;
93 typedef ExceptionTemplate<IOException, LuceneException::MergeAborted> MergeAbortedException;
94 typedef ExceptionTemplate<IOException, LuceneException::StaleReader> StaleReaderException;
95 typedef ExceptionTemplate<FileNotFoundException, LuceneException::NoSuchDirectory> NoSuchDirectoryException;
96 typedef ExceptionTemplate<LuceneException, LuceneException::Lookahead> LookaheadSuccess;
97 typedef ExceptionTemplate<LuceneException, LuceneException::Parse> ParseException;
98 typedef ExceptionTemplate<LuceneException, LuceneException::QueryParser> QueryParserError;
99 typedef ExceptionTemplate<LuceneException, LuceneException::Compression> CompressionException;
100 }
101
102 #endif

clucene.sourceforge.net