未验证 提交 f310d9af 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #6071 from dbeaver/Readable_error_message

187 No readable error message appears
......@@ -145,8 +145,10 @@ public class MySQLPlanAnalyser extends AbstractExecutionPlanSerializer implement
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<>();
......
......@@ -173,7 +173,7 @@ public class OracleQueryPlanner extends AbstractExecutionPlanSerializer impleme
JsonObject jo = new JsonParser().parse(planData).getAsJsonObject();
String query = jo.get(AbstractExecutionPlanSerializer.PROP_SQL).getAsString();
String query = getQuery(jo);
ExecutionPlanDeserializer<OraclePlanNode> loader = new ExecutionPlanDeserializer<>();
......
......@@ -18,6 +18,7 @@ package org.jkiss.dbeaver.ext.postgresql.model.plan;
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;
......@@ -103,8 +104,8 @@ public class PostgreQueryPlaner extends AbstractExecutionPlanSerializer implemen
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<>();
......
......@@ -21,9 +21,12 @@ package org.jkiss.dbeaver.model.impl.plan;
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;
......@@ -98,6 +101,32 @@ public abstract class AbstractExecutionPlanSerializer implements DBCQueryPlanne
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();
}
}
......@@ -201,8 +201,7 @@ public class ExplainPlanViewer extends Viewer implements IAdaptable
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));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册