提交 12c3cf9a authored 作者: Thomas Mueller's avatar Thomas Mueller

Don't throw Error

上级 2bc833a3
...@@ -69,7 +69,7 @@ public class Bnf { ...@@ -69,7 +69,7 @@ public class Bnf {
private RuleHead addRule(String topic, String section, Rule rule) { private RuleHead addRule(String topic, String section, Rule rule) {
RuleHead head = new RuleHead(section, topic, rule); RuleHead head = new RuleHead(section, topic, rule);
if (ruleMap.get(StringUtils.toLowerEnglish(topic)) != null) { if (ruleMap.get(StringUtils.toLowerEnglish(topic)) != null) {
throw new Error("already exists: " + topic); throw new AssertionError("already exists: " + topic);
} }
ruleMap.put(StringUtils.toLowerEnglish(topic), head); ruleMap.put(StringUtils.toLowerEnglish(topic), head);
return head; return head;
...@@ -206,13 +206,13 @@ public class Bnf { ...@@ -206,13 +206,13 @@ public class Bnf {
Rule r2 = parseOr(); Rule r2 = parseOr();
r = new RuleOptional(r2); r = new RuleOptional(r2);
if (firstChar != ']') { if (firstChar != ']') {
throw new Error("expected ], got " + currentToken + " syntax:" + syntax); throw new AssertionError("expected ], got " + currentToken + " syntax:" + syntax);
} }
} else if (firstChar == '{') { } else if (firstChar == '{') {
read(); read();
r = parseOr(); r = parseOr();
if (firstChar != '}') { if (firstChar != '}') {
throw new Error("expected }, got " + currentToken + " syntax:" + syntax); throw new AssertionError("expected }, got " + currentToken + " syntax:" + syntax);
} }
} else if ("@commaDots@".equals(currentToken)) { } else if ("@commaDots@".equals(currentToken)) {
r = new RuleList(new RuleElement(",", currentTopic), lastRepeat, false); r = new RuleList(new RuleElement(",", currentTopic), lastRepeat, false);
......
...@@ -40,7 +40,7 @@ public class RuleElement implements Rule { ...@@ -40,7 +40,7 @@ public class RuleElement implements Rule {
if (link != null) { if (link != null) {
return link.random(config, level + 1); return link.random(config, level + 1);
} }
throw new Error(name); throw new AssertionError(name);
} }
public String name() { public String name() {
...@@ -76,7 +76,7 @@ public class RuleElement implements Rule { ...@@ -76,7 +76,7 @@ public class RuleElement implements Rule {
return; return;
} }
} }
throw new Error("Unknown " + name + "/" + test); throw new AssertionError("Unknown " + name + "/" + test);
} }
public boolean matchRemove(Sentence sentence) { public boolean matchRemove(Sentence sentence) {
......
...@@ -55,7 +55,7 @@ public class RuleFixed implements Rule { ...@@ -55,7 +55,7 @@ public class RuleFixed implements Rule {
case DIGIT: case DIGIT:
return "0"; return "0";
default: default:
throw new Error("type="+type); throw new AssertionError("type="+type);
} }
} }
...@@ -92,7 +92,7 @@ public class RuleFixed implements Rule { ...@@ -92,7 +92,7 @@ public class RuleFixed implements Rule {
case DIGIT: case DIGIT:
return "" + (char) ('0' + r.nextInt(10)); return "" + (char) ('0' + r.nextInt(10));
default: default:
throw new Error("type="+type); throw new AssertionError("type="+type);
} }
} }
...@@ -213,7 +213,7 @@ public class RuleFixed implements Rule { ...@@ -213,7 +213,7 @@ public class RuleFixed implements Rule {
} }
break; break;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
if (s.equals(query)) { if (s.equals(query)) {
return false; return false;
...@@ -292,7 +292,7 @@ public class RuleFixed implements Rule { ...@@ -292,7 +292,7 @@ public class RuleFixed implements Rule {
} }
break; break;
default: default:
throw new Error("type="+type); throw new AssertionError("type="+type);
} }
} }
......
...@@ -58,7 +58,7 @@ public class RuleList implements Rule { ...@@ -58,7 +58,7 @@ public class RuleList implements Rule {
if (level > 10) { if (level > 10) {
if (level > 1000) { if (level > 1000) {
// better than stack overflow // better than stack overflow
throw new Error(); throw new AssertionError();
} }
return get(0).random(config, level); return get(0).random(config, level);
} }
......
...@@ -16,7 +16,7 @@ import java.sql.SQLException; ...@@ -16,7 +16,7 @@ import java.sql.SQLException;
*/ */
public class JdbcBatchUpdateException extends BatchUpdateException { public class JdbcBatchUpdateException extends BatchUpdateException {
private static final long serialVersionUID = 9006432914018679675L; private static final long serialVersionUID = 1L;
/** /**
* INTERNAL * INTERNAL
......
...@@ -17,7 +17,7 @@ import org.h2.engine.Constants; ...@@ -17,7 +17,7 @@ import org.h2.engine.Constants;
*/ */
public class JdbcSQLException extends SQLException { public class JdbcSQLException extends SQLException {
private static final long serialVersionUID = -8200821788226954151L; private static final long serialVersionUID = 1L;
private final String originalMessage; private final String originalMessage;
private final Throwable cause; private final Throwable cause;
private final String stackTrace; private final String stackTrace;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论