improve some exception messages and init the cause of exceptions

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@405870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2006-05-12 21:04:00 +00:00
parent cb5f472525
commit 07587e8d15
4 changed files with 14 additions and 8 deletions

View File

@ -159,7 +159,9 @@ final class FieldsReader {
}
catch (DataFormatException e) {
// this will happen if the field is not compressed
throw new IOException ("field data are in wrong format: " + e.toString());
IOException newException = new IOException("field data are in wrong format: " + e.toString());
newException.initCause(e);
throw newException;
}
}

View File

@ -332,7 +332,8 @@ final class SegmentMerger {
doc += base; // convert to merged space
if (doc < lastDoc)
throw new IllegalStateException("docs out of order");
throw new IllegalStateException("docs out of order (" + doc +
" < " + lastDoc + " )");
df++;

View File

@ -94,12 +94,12 @@ class SegmentReader extends IndexReader {
SegmentReader.class.getName());
IMPL = Class.forName(name);
} catch (ClassNotFoundException e) {
throw new RuntimeException("cannot load SegmentReader class: " + e);
throw new RuntimeException("cannot load SegmentReader class: " + e, e);
} catch (SecurityException se) {
try {
IMPL = Class.forName(SegmentReader.class.getName());
} catch (ClassNotFoundException e) {
throw new RuntimeException("cannot load default SegmentReader class: " + e);
throw new RuntimeException("cannot load default SegmentReader class: " + e, e);
}
}
}
@ -123,7 +123,7 @@ class SegmentReader extends IndexReader {
try {
instance = (SegmentReader)IMPL.newInstance();
} catch (Exception e) {
throw new RuntimeException("cannot load SegmentReader class: " + e);
throw new RuntimeException("cannot load SegmentReader class: " + e, e);
}
instance.init(dir, sis, closeDir, ownDir);
instance.initialize(si);

View File

@ -92,11 +92,14 @@ final class TermInfosWriter {
final void add(Term term, TermInfo ti)
throws IOException {
if (!isIndex && term.compareTo(lastTerm) <= 0)
throw new IOException("term out of order");
throw new IOException("term out of order (\"" + term +
"\".compareTo(\"" + lastTerm + "\") <= 0)");
if (ti.freqPointer < lastTi.freqPointer)
throw new IOException("freqPointer out of order");
throw new IOException("freqPointer out of order (" + ti.freqPointer +
" < " + lastTi.freqPointer + ")");
if (ti.proxPointer < lastTi.proxPointer)
throw new IOException("proxPointer out of order");
throw new IOException("proxPointer out of order (" + ti.proxPointer +
" < " + lastTi.proxPointer + ")");
if (!isIndex && size % indexInterval == 0)
other.add(lastTerm, lastTi); // add an index term