exception cleanup

This commit is contained in:
zzz
2011-02-08 14:26:46 +00:00
parent 54fdfd823b
commit ad3342aefb
6 changed files with 24 additions and 29 deletions

View File

@@ -25,6 +25,9 @@ Changes for i2p:
- Commented out some System.out.println()
- Convert Errors without message or cause to RuntimeExceptions with a message and cause
TODO:
- Change PAGESIZE from default 1024 to 4096? No, wastes too much disk.

View File

@@ -91,13 +91,13 @@ public class BSkipLevels extends SkipLevels {
if(levels[i]==null) { break; }
bf.file.writeInt(((BSkipLevels) levels[i]).levelPage);
}
} catch (IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
}
public void killInstance() {
try {
bf.freePage(levelPage);
} catch (IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
}
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) {
@@ -107,6 +107,6 @@ public class BSkipLevels extends SkipLevels {
int page = bf.allocPage();
BSkipLevels.init(bf, page, bss.page, levels);
return new BSkipLevels(bf, page, bsl);
} catch (IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
}
}

View File

@@ -53,7 +53,7 @@ public class BSkipList extends SkipList {
}
public BSkipList(int spanSize, BlockFile bf, int skipPage, Serializer key, Serializer val, boolean fileOnly) throws IOException {
if(spanSize < 1) { throw new Error("Span size too small"); }
if(spanSize < 1) { throw new RuntimeException("Span size too small"); }
this.skipPage = skipPage;
this.bf = bf;
@@ -88,7 +88,7 @@ public class BSkipList extends SkipList {
bf.file.writeInt(size);
bf.file.writeInt(spans);
} catch (IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
}
public void delete() throws IOException {

View File

@@ -65,7 +65,7 @@ public class BSkipSpan extends SkipSpan {
int newPage = bf.allocPage();
init(bf, newPage, bf.spanSize);
return new BSkipSpan(bf, (BSkipList) sl, newPage, keySer, valSer);
} catch (IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
}
public void killInstance() {
@@ -79,7 +79,7 @@ public class BSkipSpan extends SkipSpan {
curPage = next;
}
bf.freePage(page);
} catch(IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
}
public void flush() {
@@ -124,7 +124,7 @@ public class BSkipSpan extends SkipSpan {
}
BlockFile.pageSeek(bf.file, this.page);
this.overflowPage = bf.file.readInt();
} catch(IOException ioe) { throw new Error(); }
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
}
private static void load(BSkipSpan bss, BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {

View File

@@ -69,7 +69,7 @@ public class IBSkipSpan extends BSkipSpan {
rv.keys = new Comparable[bf.spanSize];
rv.vals = new Object[bf.spanSize];
return rv;
} catch (IOException ioe) { throw new Error(ioe); }
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
}
/**
@@ -247,7 +247,7 @@ public class IBSkipSpan extends BSkipSpan {
try {
seekAndLoadData();
} catch (IOException ioe) {
throw new Error(ioe);
throw new RuntimeException("Error reading database", ioe);
}
SkipSpan rv = super.getSpan(key, search);
this.keys = null;
@@ -266,7 +266,7 @@ public class IBSkipSpan extends BSkipSpan {
return next.get(key);
return getData(key);
} catch (IOException ioe) {
throw new Error(ioe);
throw new RuntimeException("Error reading database", ioe);
}
}
@@ -278,7 +278,7 @@ public class IBSkipSpan extends BSkipSpan {
try {
seekAndLoadData();
} catch (IOException ioe) {
throw new Error(ioe);
throw new RuntimeException("Error reading database", ioe);
}
SkipSpan rv = super.put(key, val, sl);
// flush() nulls out the data
@@ -293,7 +293,7 @@ public class IBSkipSpan extends BSkipSpan {
try {
seekAndLoadData();
} catch (IOException ioe) {
throw new Error(ioe);
throw new RuntimeException("Error reading database", ioe);
}
Object[] rv = super.remove(key, sl);
// flush() nulls out the data