Skip to content

Commit

Permalink
Merge pull request #6071 from dbeaver/Readable_error_message
Browse files Browse the repository at this point in the history
187 No readable error message appears
  • Loading branch information
serge-rider committed Jun 7, 2019
2 parents cf992d1 + 793f1bc commit f310d9a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ private static Map<String, String> getNodeAttributes(JsonObject nodeObject){
public DBCPlan deserialize(@NotNull Reader planData) throws IOException, InvocationTargetException {

JsonObject jo = new JsonParser().parse(planData).getAsJsonObject();
String savedVersion = jo.get(AbstractExecutionPlanSerializer.PROP_VERSION).getAsString();
String query = jo.get(AbstractExecutionPlanSerializer.PROP_SQL).getAsString();

String savedVersion = getVersion(jo);

String query = getQuery(jo);

if (savedVersion.equals("classic")) {
ExecutionPlanDeserializer<MySQLPlanNodePlain> loader = new ExecutionPlanDeserializer<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public DBCPlan deserialize(@NotNull Reader planData) throws IOException,Invocati

JsonObject jo = new JsonParser().parse(planData).getAsJsonObject();

String query = jo.get(AbstractExecutionPlanSerializer.PROP_SQL).getAsString();
String query = getQuery(jo);

ExecutionPlanDeserializer<OraclePlanNode> loader = new ExecutionPlanDeserializer<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
Expand Down Expand Up @@ -103,8 +104,8 @@ public void addNodeProperties(DBCPlanNode node, JsonObject nodeJson) {
public DBCPlan deserialize(@NotNull Reader planData) throws IOException, InvocationTargetException {
try {
JsonObject jo = new JsonParser().parse(planData).getAsJsonObject();

String query = jo.get(AbstractExecutionPlanSerializer.PROP_SQL).getAsString();
String query = getQuery(jo);

ExecutionPlanDeserializer<PostgrePlanNodeExternal> loader = new ExecutionPlanDeserializer<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@

import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;

import com.google.gson.*;

import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.exec.plan.DBCPlan;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlannerSerialInfo;
Expand Down Expand Up @@ -98,6 +101,32 @@ protected void serializeJson(Writer writer, DBCPlan plan, String signature, DBCQ

writer.write(gson.toJson(root));
}

protected String getVersion(@NotNull JsonObject o) throws InvocationTargetException {

JsonElement queryElement = o.get(AbstractExecutionPlanSerializer.PROP_VERSION);

if (queryElement == null) {

throw new InvocationTargetException(new Exception("Incorrect file format"));

}

return queryElement.getAsString();
}

protected String getQuery(@NotNull JsonObject o) throws InvocationTargetException {

JsonElement queryElement = o.get(AbstractExecutionPlanSerializer.PROP_SQL);

if (queryElement == null) {

throw new InvocationTargetException(new Exception("Incorrect file format"));

}

return queryElement.getAsString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ public boolean loadQueryPlan(DBCQueryPlanner planner, Viewer viewer) {
return true;

} catch (IOException | InvocationTargetException e) {
DBWorkbench.getPlatformUI().showError("Load plan", "Error loading plan ",
(e.getCause() != null) ? e.getCause().getCause() : e);
DBWorkbench.getPlatformUI().showError("Load plan", "Error loading plan ",GeneralUtils.getRootCause(e));
}
}
}
Expand Down

0 comments on commit f310d9a

Please sign in to comment.