提交 78375e9f authored 作者: Thomas Mueller's avatar Thomas Mueller

The stack trace of very common exceptions is no longer written to the .trace.db file by default.

上级 1dcddbf3
...@@ -1872,6 +1872,29 @@ public class ErrorCode { ...@@ -1872,6 +1872,29 @@ public class ErrorCode {
// utility class // utility class
} }
/**
* INTERNAL
*/
public static boolean isCommon(int errorCode) {
switch (errorCode) {
case DATA_CONVERSION_ERROR_1:
case DUPLICATE_KEY_1:
case LOCK_TIMEOUT_1:
case NULL_NOT_ALLOWED:
case NO_DATA_AVAILABLE:
case REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1:
case REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1:
case SYNTAX_ERROR_1:
case SYNTAX_ERROR_2:
case TABLE_OR_VIEW_ALREADY_EXISTS_1:
case TABLE_OR_VIEW_NOT_FOUND_1:
case VALUE_TOO_LARGE_FOR_PRECISION_1:
case VALUE_TOO_LONG_2:
return true;
}
return false;
}
/** /**
* INTERNAL * INTERNAL
*/ */
......
...@@ -17,6 +17,7 @@ import java.util.Date; ...@@ -17,6 +17,7 @@ import java.util.Date;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.jdbc.JdbcSQLException;
import org.h2.util.ClassUtils; import org.h2.util.ClassUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
...@@ -257,7 +258,17 @@ public class TraceSystem implements TraceWriter { ...@@ -257,7 +258,17 @@ public class TraceSystem implements TraceWriter {
} }
printWriter.println(s); printWriter.println(s);
if (t != null) { if (t != null) {
t.printStackTrace(printWriter); if (levelFile == ERROR && t instanceof JdbcSQLException) {
JdbcSQLException se = (JdbcSQLException) t;
int code = se.getErrorCode();
if (ErrorCode.isCommon(code)) {
printWriter.println(t.toString());
} else {
t.printStackTrace(printWriter);
}
} else {
t.printStackTrace(printWriter);
}
} }
printWriter.flush(); printWriter.flush();
if (closed) { if (closed) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论