From 28a4dd0ff53f27f64cb5fb11e95f01d741d9749d Mon Sep 17 00:00:00 2001 From: skai273 Date: Sun, 11 May 2025 16:15:08 +0900 Subject: [PATCH] fix env error handling --- src/client/pythonEnvironments/legacyIOC.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client/pythonEnvironments/legacyIOC.ts b/src/client/pythonEnvironments/legacyIOC.ts index 9d161f8b1b9f..a1a1b841a16f 100644 --- a/src/client/pythonEnvironments/legacyIOC.ts +++ b/src/client/pythonEnvironments/legacyIOC.ts @@ -26,7 +26,7 @@ import { asyncFilter } from '../common/utils/arrayUtils'; import { CondaEnvironmentInfo, isCondaEnvironment } from './common/environmentManagers/conda'; import { isMicrosoftStoreEnvironment } from './common/environmentManagers/microsoftStoreEnv'; import { CondaService } from './common/environmentManagers/condaService'; -import { traceVerbose } from '../logging'; +import { traceError, traceVerbose } from '../logging'; const convertedKinds = new Map( Object.entries({ @@ -159,11 +159,16 @@ class ComponentAdapter implements IComponentAdapter { // We use the same getInterpreters() here as for IInterpreterLocatorService. public async getInterpreterDetails(pythonPath: string): Promise { - const env = await this.api.resolveEnv(pythonPath); - if (!env) { + try { + const env = await this.api.resolveEnv(pythonPath); + if (!env) { + return undefined; + } + return convertEnvInfo(env); + } catch (ex) { + traceError(`Failed to resolve interpreter: ${pythonPath}`, ex); return undefined; } - return convertEnvInfo(env); } // Implements ICondaService