Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/java/com/dieselpoint/norm/DbException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@
*/
public class DbException extends RuntimeException {

private String sql;

public DbException() {}
private final String sql;

public DbException(String msg) {
super(msg);
sql = null;
}

public DbException(Throwable t) {
super(t);
sql = null;
}

public DbException(String msg, Throwable t) {
super(msg, t);
public DbException(Throwable t, String sql) {
super(t);
this.sql = sql;
}

public void setSql(String sql) {
this.sql = sql;

public DbException(String msg, Throwable t) {
super(msg, t);
sql = null;
}

public String getSql() {
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/dieselpoint/norm/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ public <T> List<T> results(Class<T> clazz) {

} catch (InstantiationException | IllegalAccessException | SQLException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
DbException dbe = new DbException(e);
dbe.setSql(sql);
throw dbe;
throw new DbException(e, sql);
} finally {
close(state);
close(con);
Expand Down Expand Up @@ -349,9 +347,7 @@ public Query execute() {
}

} catch (SQLException | IllegalArgumentException e) {
DbException dbe = new DbException(e);
dbe.setSql(sql);
throw dbe;
throw new DbException(e, sql );
} finally {
close(state);
close(con);
Expand Down