Skip to content

Commit

Permalink
Merge pull request #42284 from Thevakumar-Luheerathan/fix-ballerina-l…
Browse files Browse the repository at this point in the history
…ang-iss-42235

Fix bad sad error occurs when pulling a non-existing tool from local repository
  • Loading branch information
Thevakumar-Luheerathan authored Mar 7, 2024
2 parents ff343cd + d049c44 commit f3db542
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package io.ballerina.cli.cmd;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.ballerina.cli.BLauncherCmd;
import io.ballerina.cli.utils.PrintUtils;
Expand Down Expand Up @@ -495,7 +496,11 @@ private boolean isToolAvailableInLocalRepo(String toolId, String version) {
}
try (BufferedReader bufferedReader = Files.newBufferedReader(localToolJsonPath, StandardCharsets.UTF_8)) {
localToolJson = gson.fromJson(bufferedReader, JsonObject.class);
JsonObject pkgDesc = localToolJson.get(toolId).getAsJsonObject();
JsonElement localTool = localToolJson.get(toolId);
if (localTool == null) {
return false;
}
JsonObject pkgDesc = localTool.getAsJsonObject();
if (pkgDesc.isEmpty()) {
return false;
}
Expand Down

0 comments on commit f3db542

Please sign in to comment.