Add exception handling to non selects
This commit is contained in:
@@ -41,8 +41,15 @@ public class SqlExecutor {
|
||||
@Cleanup
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
try {
|
||||
stmt.execute(sql.trim());
|
||||
log.info("Executed");
|
||||
} catch (SQLException e) {
|
||||
return Result.builder() //
|
||||
.exception(e.getClass().getName()) //
|
||||
.exceptionMessage(e.getMessage()) //
|
||||
.build();
|
||||
}
|
||||
|
||||
ResultBuilder resultBuilder = Result.builder();
|
||||
|
||||
|
@@ -2,6 +2,8 @@ package at.compax.tools.sql.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
@@ -9,6 +11,9 @@ import lombok.ToString;
|
||||
@Builder
|
||||
@Getter
|
||||
@ToString
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Result {
|
||||
private List<UserError> userErrors;
|
||||
private String exception;
|
||||
private String exceptionMessage;
|
||||
}
|
||||
|
Reference in New Issue
Block a user