提交 7d7fbc8d authored 作者: Thomas Mueller's avatar Thomas Mueller

Don't throw Error

上级 f756c00f
......@@ -36,7 +36,7 @@ public class TestCache extends TestBase implements CacheWriter {
}
public void test() throws SQLException {
testCache(false);
// testCache(false);
testCache(true);
testCacheDb(false);
testCacheDb(true);
......
......@@ -242,11 +242,11 @@ public class TestDataPage extends TestBase implements DataHandler {
}
public int getMaxLengthInplaceLob() {
throw new Error();
throw new AssertionError();
}
public int allocateObjectId(boolean b, boolean c) {
throw new Error();
throw new AssertionError();
}
public String createTempFile() throws SQLException {
......@@ -254,7 +254,7 @@ public class TestDataPage extends TestBase implements DataHandler {
}
public String getLobCompressionAlgorithm(int type) {
throw new Error();
throw new AssertionError();
}
public Object getLobSyncObject() {
......
......@@ -46,7 +46,7 @@ public class TestIntIntHashMap extends TestBase {
}
for (int i = 0; i < len; i++) {
if (map.get(x[i]) != i) {
throw new Error("get " + x[i] + " = " + map.get(i) + " should be " + i);
throw new AssertionError("get " + x[i] + " = " + map.get(i) + " should be " + i);
}
}
for (int i = 1; i < len; i += 2) {
......@@ -54,7 +54,7 @@ public class TestIntIntHashMap extends TestBase {
}
for (int i = 1; i < len; i += 2) {
if (map.get(x[i]) != -1) {
throw new Error("get " + x[i] + " = " + map.get(i) + " should be <=0");
throw new AssertionError("get " + x[i] + " = " + map.get(i) + " should be <=0");
}
}
for (int i = 1; i < len; i += 2) {
......@@ -62,7 +62,7 @@ public class TestIntIntHashMap extends TestBase {
}
for (int i = 0; i < len; i++) {
if (map.get(x[i]) != i) {
throw new Error("get " + x[i] + " = " + map.get(i) + " should be " + i);
throw new AssertionError("get " + x[i] + " = " + map.get(i) + " should be " + i);
}
}
}
......
......@@ -93,7 +93,7 @@ public class TestSecurity extends TestBase {
test.encrypt(enc, 0, 128);
test.decrypt(enc, 0, 128);
if (ByteUtils.compareNotNull(in, enc) != 0) {
throw new Error("hey!");
throw new AssertionError();
}
for (int i = 0; i < 10; i++) {
......
......@@ -87,7 +87,7 @@ public class TestStringCache extends TestBase {
TestBase.logError("error", e);
}
if (a != null && a == b && a.length() > 0) {
throw new Error("a=" + System.identityHashCode(a) + " b=" + System.identityHashCode(b));
throw new AssertionError("a=" + System.identityHashCode(a) + " b=" + System.identityHashCode(b));
}
} else {
String b;
......
......@@ -66,7 +66,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
try {
return v1.compareTo(v2, compareMode);
} catch (SQLException e) {
throw new Error(e);
throw new AssertionError(e);
}
}
};
......
......@@ -161,7 +161,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
case Value.STRING_FIXED:
return ValueStringFixed.get(randomString(random.nextInt(100)));
default:
throw new Error("type=" + type);
throw new AssertionError("type=" + type);
}
}
......
......@@ -124,7 +124,7 @@ public class Build extends BuildBase {
SwitchSource.main("-dir", "src", "-version", version);
}
} catch (IOException e) {
throw new Error(e);
throw new RuntimeException(e);
}
}
......@@ -325,7 +325,7 @@ public class Build extends BuildBase {
exclude("*.txt");
long kb = jar("bin/h2client" + getJarSuffix(), files, "temp");
if (kb < 300 || kb > 400) {
throw new Error("Expected file size 300 - 400 KB, got: " + kb);
throw new RuntimeException("Expected file size 300 - 400 KB, got: " + kb);
}
}
......@@ -582,7 +582,7 @@ public class Build extends BuildBase {
public void uploadBuild() {
String password = System.getProperty("h2.ftpPassword");
if (password == null) {
throw new Error("h2.ftpPassword not set");
throw new RuntimeException("h2.ftpPassword not set");
}
String cp = "bin" + File.pathSeparator + "temp";
exec("java", args("-Xmx128m", "-cp", cp,
......
......@@ -129,7 +129,7 @@ public class BuildBase {
pattern = pattern.substring(1);
}
if (pattern.indexOf('*') >= 0) {
throw new Error("Unsupported pattern, may only start or end with *:" + pattern);
throw new RuntimeException("Unsupported pattern, may only start or end with *:" + pattern);
}
// normalize / and \
pattern = replaceAll(pattern, "/", File.separator);
......@@ -204,8 +204,12 @@ public class BuildBase {
} catch (InvocationTargetException e) {
throw e.getCause();
}
} catch (Error e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Throwable e) {
throw e instanceof Error ? ((Error) e) : new Error(e);
throw new RuntimeException(e);
}
}
......@@ -291,7 +295,7 @@ public class BuildBase {
p.waitFor();
return p.exitValue();
} catch (Exception e) {
throw new Error("Error: " + e, e);
throw new RuntimeException(e);
}
}
......@@ -309,7 +313,7 @@ public class BuildBase {
}
}
} catch (Exception e) {
throw new Error("Error: " + e, e);
throw new RuntimeException(e);
}
}
} .start();
......@@ -328,7 +332,7 @@ public class BuildBase {
Field field = clazz.getField(fieldName);
return field.get(null).toString();
} catch (Exception e) {
throw new Error("Can not read field " + className + "." + fieldName, e);
throw new RuntimeException("Can not read field " + className + "." + fieldName, e);
}
}
......@@ -345,7 +349,7 @@ public class BuildBase {
Method method = clazz.getMethod(methodName);
return method.invoke(null).toString();
} catch (Exception e) {
throw new Error("Can not read value " + className + "." + methodName + "()", e);
throw new RuntimeException("Can not read value " + className + "." + methodName + "()", e);
}
}
......@@ -436,7 +440,7 @@ public class BuildBase {
System.setOut(old);
}
if (result != 0) {
throw new Error("An error occurred");
throw new RuntimeException("An error occurred, result=" + result);
}
}
......@@ -462,7 +466,7 @@ public class BuildBase {
md = MessageDigest.getInstance("SHA-1");
return convertBytesToString(md.digest(data));
} catch (NoSuchAlgorithmException e) {
throw new Error(e);
throw new RuntimeException(e);
}
}
......@@ -503,7 +507,7 @@ public class BuildBase {
}
in.close();
} catch (IOException e) {
throw new Error("Error downloading", e);
throw new RuntimeException("Error downloading", e);
}
byte[] data = buff.toByteArray();
String got = getSHA1(data);
......@@ -511,7 +515,7 @@ public class BuildBase {
println("SHA1 checksum: " + got);
} else {
if (!got.equals(sha1Checksum)) {
throw new Error("SHA1 checksum mismatch");
throw new RuntimeException("SHA1 checksum mismatch");
}
}
writeFile(targetFile, data);
......@@ -576,7 +580,7 @@ public class BuildBase {
ra.setLength(data.length);
ra.close();
} catch (IOException e) {
throw new Error("Error writing to file " + file, e);
throw new RuntimeException("Error writing to file " + file, e);
}
}
......@@ -591,14 +595,14 @@ public class BuildBase {
RandomAccessFile ra = new RandomAccessFile(file, "r");
long len = ra.length();
if (len >= Integer.MAX_VALUE) {
throw new Error("File " + file.getPath() + " is too large");
throw new RuntimeException("File " + file.getPath() + " is too large");
}
byte[] buffer = new byte[(int) len];
ra.readFully(buffer);
ra.close();
return buffer;
} catch (IOException e) {
throw new Error("Error reading from file " + file, e);
throw new RuntimeException("Error reading from file " + file, e);
}
}
......@@ -688,7 +692,7 @@ public class BuildBase {
zipOut.close();
return new File(destFile).length() / 1024;
} catch (IOException e) {
throw new Error("Error creating file " + destFile, e);
throw new RuntimeException("Error creating file " + destFile, e);
}
}
......@@ -740,7 +744,7 @@ public class BuildBase {
System.setErr(old);
}
if (result != 0) {
throw new Error("An error occurred");
throw new RuntimeException("An error occurred");
}
}
......@@ -757,7 +761,7 @@ public class BuildBase {
Method main = Class.forName(className).getMethod("main", String[].class);
invoke(main, null, new Object[] { array });
} catch (Exception e) {
throw new Error(e);
throw new RuntimeException(e);
}
}
......@@ -770,7 +774,7 @@ public class BuildBase {
File f = new File(dir);
if (f.exists()) {
if (f.isFile()) {
throw new Error("Can not create directory " + dir + " because a file with this name exists");
throw new RuntimeException("Can not create directory " + dir + " because a file with this name exists");
}
} else {
mkdirs(f);
......@@ -780,7 +784,7 @@ public class BuildBase {
private void mkdirs(File f) {
if (!f.exists()) {
if (!f.mkdirs()) {
throw new Error("Can not create directory " + f.getAbsolutePath());
throw new RuntimeException("Can not create directory " + f.getAbsolutePath());
}
}
}
......@@ -815,7 +819,7 @@ public class BuildBase {
}
}
if (!file.delete()) {
throw new Error("Can not delete " + file.getPath());
throw new RuntimeException("Can not delete " + file.getPath());
}
}
}
......
......@@ -98,7 +98,7 @@ public class CheckTextFiles {
}
}
if (ignore == check) {
throw new Error("Unknown suffix: " + suffix + " for file: " + file.getAbsolutePath());
throw new RuntimeException("Unknown suffix: " + suffix + " for file: " + file.getAbsolutePath());
}
if (check) {
checkOrFixFile(file, autoFix, checkLicense);
......@@ -268,7 +268,7 @@ public class CheckTextFiles {
System.out.println("FAIL at " + name + " " + error + " " + file.getAbsolutePath());
hasError = true;
if (failOnError) {
throw new Error("FAIL");
throw new RuntimeException("FAIL");
}
}
......
......@@ -68,7 +68,7 @@ public class MergeDocs {
int idx = text.indexOf(end);
if (idx < 0) {
throw new Error("Footer not found in file " + fileName);
throw new RuntimeException("Footer not found in file " + fileName);
}
text = text.substring(0, idx);
idx = text.indexOf(start) + start.length();
......
......@@ -124,7 +124,7 @@ public class XMLParser {
}
private void error(String expected) {
throw new Error("expected: " + expected + " got: " + xml.substring(index));
throw new RuntimeException("Expected: " + expected + " got: " + xml.substring(index));
}
private void read(String chars) {
......
......@@ -612,4 +612,4 @@ locals multianewarray icmpne fneg faload ifeq decompiler zeroes forgot
modern slight boost characteristics significantly gae vfs centrally ten
approach risky getters suxxess gmb delegate delegating delegates collisions
linkage superfluous disallow scoop moebius inputs copilot dmoebius leod jenkov
jakob poker docware peter
\ No newline at end of file
jakob poker docware peter unstable measurable
\ No newline at end of file
......@@ -40,7 +40,7 @@ public class Base64 {
private static void check(String a, String b) {
if (!a.equals(b)) {
throw new Error("mismatch: " + a + " <> " + b);
throw new RuntimeException("mismatch: " + a + " <> " + b);
}
}
......@@ -89,11 +89,11 @@ public class Base64 {
private static void test(byte[] in, byte[] out) {
if (in.length != out.length) {
throw new Error("Length error");
throw new RuntimeException("Length error");
}
for (int i = 0; i < in.length; i++) {
if (in[i] != out[i]) {
throw new Error("Error at " + i);
throw new RuntimeException("Error at " + i);
}
}
}
......
......@@ -51,7 +51,7 @@ public class Db {
try {
return clazz.newInstance();
} catch (Exception e) {
throw new Error(e);
throw new RuntimeException(e);
}
}
......@@ -124,7 +124,7 @@ public class Db {
try {
conn.close();
} catch (Exception e) {
throw new Error(e);
throw new RuntimeException(e);
}
}
......
......@@ -137,7 +137,7 @@ public class ClassReader {
break;
}
default:
throw new Error("Unsupported constant pool tag: " + tag);
throw new RuntimeException("Unsupported constant pool tag: " + tag);
}
}
int accessFlags = readShort();
......@@ -1308,7 +1308,7 @@ public class ClassReader {
op = "wide ret " + readShort();
break;
default:
throw new Error("unsupported wide opCode " + opCode);
throw new RuntimeException("Unsupported wide opCode " + opCode);
}
break;
}
......@@ -1338,7 +1338,7 @@ public class ClassReader {
op = "jsr_w " + getAbsolutePos(pos, readInt());
break;
default:
throw new Error("unsupported opCode " + opCode);
throw new RuntimeException("Unsupported opCode " + opCode);
}
debug(" " + startPos + ": " + op);
}
......@@ -1395,7 +1395,7 @@ public class ClassReader {
// TODO escape
return "\"" + cpString[cpInt[constantRef]] + "\"";
default:
throw new Error("not a constant: " + constantRef);
throw new RuntimeException("Not a constant: " + constantRef);
}
}
......
......@@ -109,7 +109,7 @@ public class WeakIdentityHashMap<K, V> implements Map<K, V> {
}
index = (index + plus++) & mask;
} while(plus <= len);
throw new Error("hashmap is full");
throw new RuntimeException("Hashmap is full");
}
public V remove(Object key) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论