提交 2e9d60d5 authored 作者: Thomas Mueller's avatar Thomas Mueller

better error messages

上级 8d7c763f
...@@ -139,7 +139,7 @@ public abstract class Command implements CommandInterface { ...@@ -139,7 +139,7 @@ public abstract class Command implements CommandInterface {
session.setCurrentCommand(this, startTime); session.setCurrentCommand(this, startTime);
return query(maxrows); return query(maxrows);
} catch (Exception e) { } catch (Exception e) {
SQLException s = Message.convert(e); SQLException s = Message.convert(e, sql);
database.exceptionThrown(s, sql); database.exceptionThrown(s, sql);
throw s; throw s;
} finally { } finally {
......
...@@ -221,6 +221,22 @@ public class Message { ...@@ -221,6 +221,22 @@ public class Message {
* Convert an exception to a SQL exception using the default mapping. * Convert an exception to a SQL exception using the default mapping.
* *
* @param e the root cause * @param e the root cause
* @param sql the SQL statement or null if it is not known
* @return the SQL exception object
*/
public static SQLException convert(Throwable e, String sql) {
SQLException e2 = convert(e);
if (e2 instanceof JdbcSQLException) {
((JdbcSQLException) e).setSQL(sql);
}
return e2;
}
/**
* Convert an exception to a SQL exception using the default mapping.
*
* @param e the root cause
* @param sql the SQL statement or null if it is not known
* @return the SQL exception object * @return the SQL exception object
*/ */
public static SQLException convert(Throwable e) { public static SQLException convert(Throwable e) {
......
...@@ -270,18 +270,9 @@ java org.h2.test.TestAll timer ...@@ -270,18 +270,9 @@ java org.h2.test.TestAll timer
/* /*
JaQu JaQu
try java.lang.instrumentation.*
fix checkstyle
row level locking row level locking
embedded + clustering (feature request)
start server with connection
jazoon
H2 Console should support Java Queries H2 Console should support Java Queries
C:\download\Data Concurrency and Consistency.pdf C:\download\Data Concurrency and Consistency.pdf
......
...@@ -481,10 +481,10 @@ public abstract class TestBase { ...@@ -481,10 +481,10 @@ public abstract class TestBase {
} }
int al = expected.length(); int al = expected.length();
int bl = actual.length(); int bl = actual.length();
if (al > 100) { if (al > 400) {
expected = expected.substring(0, 400); expected = expected.substring(0, 400);
} }
if (bl > 100) { if (bl > 400) {
actual = actual.substring(0, 400); actual = actual.substring(0, 400);
} }
fail("Expected: " + expected + " (" + al + ") actual: " + actual + " (" + bl + ")"); fail("Expected: " + expected + " (" + al + ") actual: " + actual + " (" + bl + ")");
......
create table test$test(id int);
drop table test$test;
create table test$$test(id int);
drop table test$$test;
create table test (id varchar(36) as random_uuid() primary key); create table test (id varchar(36) as random_uuid() primary key);
insert into test() values(); insert into test() values();
delete from test where id = select id from test; delete from test where id = select id from test;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论