From bf39e2761a48a5ef5231183db1d745075acbcaf1 Mon Sep 17 00:00:00 2001 From: Dima Abramovich <60742964+dimacodota@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:47:02 +0200 Subject: [PATCH] DEV2-4448 do not faile on missing sdk (#1401) --- src/languages/java/JavaHome.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/languages/java/JavaHome.ts b/src/languages/java/JavaHome.ts index 49e6075ce2..6426f938ad 100644 --- a/src/languages/java/JavaHome.ts +++ b/src/languages/java/JavaHome.ts @@ -1,4 +1,5 @@ import { extensions } from "vscode"; +import { Logger } from "../../utils/logger"; interface RequirementsData { tooling_jre: string; @@ -11,9 +12,16 @@ interface JavaExtensionAPI { } export function getJavaHomePath(): string | undefined { - const javaExension = extensions.getExtension("redhat.java"); - if (javaExension?.isActive) { - return javaExension.exports.javaRequirement.java_home; + try { + const javaExension = extensions.getExtension( + "redhat.java" + ); + if (javaExension?.isActive) { + return javaExension.exports.javaRequirement.java_home; + } + return undefined; + } catch (e) { + Logger.error(`Failde to get java sdk information: ${e}`); + return undefined; } - return undefined; }