@@ -18,8 +18,9 @@ import {
1818 RefreshEnvironmentsScope ,
1919 ResolveEnvironmentContext ,
2020 SetEnvironmentScope ,
21- } from '../../api' ;
22- import { computeCacheKey } from '../../common/inlineScriptCacheKey' ;
21+ } from '../../../api' ;
22+ import { getErrorMessage } from '../../../common/errors/utils' ;
23+ import { computeCacheKey } from '../../../common/inlineScript/cacheKey' ;
2324import {
2425 META_SCHEMA_VERSION ,
2526 getBaseInterpreterStatus ,
@@ -29,21 +30,21 @@ import {
2930 inspectMetaJson ,
3031 resolveCacheEntryPath ,
3132 writeMetaJson ,
32- } from '../../common/inlineScriptCacheLayout ' ;
33- import { pickCompatibleInterpreter } from '../../common/inlineScriptInterpreter ' ;
33+ } from '../../../ common/inlineScript/cacheLayout ' ;
34+ import { pickCompatibleInterpreter } from '../../../ common/inlineScript/interpreter ' ;
3435import {
3536 InlineScriptMetadata ,
3637 matchesPythonVersion ,
3738 readInlineScriptMetadataFromFile ,
38- } from '../../common/inlineScriptMetadata ' ;
39- import { CONDA_MANAGER_ID , PYENV_MANAGER_ID , SYSTEM_MANAGER_ID } from '../../common/constants' ;
40- import { acquireFileLock , AcquiredFileLock } from '../../common/lockfile.apis' ;
41- import { isFileNotFoundError } from '../../common/utils/filesystem' ;
42- import { normalizePath } from '../../common/utils/pathUtils' ;
43- import { compareReleaseSegments , parseReleaseSegments } from '../../common/utils/pep440Release' ;
44- import { getVenvPythonPath } from '../../common/utils/virtualEnvironment' ;
45- import { NativePythonFinder } from '../common/nativePythonFinder' ;
46- import { createWithProgress , resolveVenvPythonEnvironmentPath } from './venvUtils' ;
39+ } from '../../../ common/inlineScript/metadata ' ;
40+ import { CONDA_MANAGER_ID , PYENV_MANAGER_ID , SYSTEM_MANAGER_ID } from '../../../ common/constants' ;
41+ import { acquireFileLock , AcquiredFileLock } from '../../../ common/lockfile.apis' ;
42+ import { isFileNotFoundError } from '../../../ common/utils/filesystem' ;
43+ import { normalizePath } from '../../../ common/utils/pathUtils' ;
44+ import { compareReleaseSegments , parseReleaseSegments } from '../../../ common/utils/pep440Release' ;
45+ import { getVenvPythonPath } from '../../../ common/utils/virtualEnvironment' ;
46+ import { NativePythonFinder } from '../../ common/nativePythonFinder' ;
47+ import { createWithProgress , resolveVenvPythonEnvironmentPath } from '.. /venvUtils' ;
4748
4849const BASE_INTERPRETER_MANAGER_IDS = new Set ( [
4950 SYSTEM_MANAGER_ID ,
@@ -160,7 +161,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
160161 }
161162 }
162163 } catch ( error ) {
163- this . log . error ( `Failed to set up inline-script environment: ${ this . errorMessage ( error ) } ` ) ;
164+ this . log . error ( `Failed to set up inline-script environment: ${ getErrorMessage ( error ) } ` ) ;
164165 return undefined ;
165166 }
166167 }
@@ -230,7 +231,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
230231 return { environment, canonicalPath : await fs . realpath ( executable ) } ;
231232 } catch ( error ) {
232233 this . log . warn (
233- `Skipping base interpreter that cannot be resolved at ${ executable } : ${ this . errorMessage ( error ) } ` ,
234+ `Skipping base interpreter that cannot be resolved at ${ executable } : ${ getErrorMessage ( error ) } ` ,
234235 ) ;
235236 }
236237 }
@@ -277,20 +278,20 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
277278 await lock . retain ( ) ;
278279 } catch ( error ) {
279280 this . log . error (
280- `Failed to mark the inline-script cache lock as retained: ${ this . errorMessage ( error ) } ` ,
281+ `Failed to mark the inline-script cache lock as retained: ${ getErrorMessage ( error ) } ` ,
281282 ) ;
282283 }
283284 }
284285 return build . environment ;
285286 } catch ( error ) {
286- this . log . error ( `Failed to create or reuse inline-script cache entry: ${ this . errorMessage ( error ) } ` ) ;
287+ this . log . error ( `Failed to create or reuse inline-script cache entry: ${ getErrorMessage ( error ) } ` ) ;
287288 return undefined ;
288289 } finally {
289290 if ( lock ) {
290291 try {
291292 await lock . release ( ) ;
292293 } catch ( error ) {
293- this . log . warn ( `Failed to release inline-script cache lock: ${ this . errorMessage ( error ) } ` ) ;
294+ this . log . warn ( `Failed to release inline-script cache lock: ${ getErrorMessage ( error ) } ` ) ;
294295 }
295296 }
296297 }
@@ -315,7 +316,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
315316 try {
316317 resolvedEntry = await resolveCacheEntryPath ( cacheRoot , envDir ) ;
317318 } catch ( error ) {
318- this . log . warn ( `Failed to resolve inline-script cache entry: ${ this . errorMessage ( error ) } ` ) ;
319+ this . log . warn ( `Failed to resolve inline-script cache entry: ${ getErrorMessage ( error ) } ` ) ;
319320 return { kind : 'uncertain' } ;
320321 }
321322 if ( ! resolvedEntry ) {
@@ -369,7 +370,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
369370 try {
370371 await writeMetaJson ( envDir , { ...sidecar , lastUsedAt : new Date ( ) . toISOString ( ) } ) ;
371372 } catch ( error ) {
372- this . log . warn ( `Failed to update inline-script cache metadata: ${ this . errorMessage ( error ) } ` ) ;
373+ this . log . warn ( `Failed to update inline-script cache metadata: ${ getErrorMessage ( error ) } ` ) ;
373374 }
374375 return { kind : 'reusable' , environment } ;
375376 }
@@ -394,7 +395,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
394395 false , // trackUvEnvironment
395396 ) ;
396397 } catch ( error ) {
397- this . log . error ( `Failed to build inline-script environment: ${ this . errorMessage ( error ) } ` ) ;
398+ this . log . error ( `Failed to build inline-script environment: ${ getErrorMessage ( error ) } ` ) ;
398399 await this . removeCacheEntry ( envDir ) ;
399400 return { } ;
400401 }
@@ -429,7 +430,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
429430 lastUsedAt : new Date ( ) . toISOString ( ) ,
430431 } ) ;
431432 } catch ( error ) {
432- this . log . error ( `Failed to record inline-script cache metadata: ${ this . errorMessage ( error ) } ` ) ;
433+ this . log . error ( `Failed to record inline-script cache metadata: ${ getErrorMessage ( error ) } ` ) ;
433434 await this . removeCacheEntry ( envDir ) ;
434435 return { } ;
435436 }
@@ -442,7 +443,7 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
442443 await fs . remove ( envDir . fsPath ) ;
443444 return true ;
444445 } catch ( error ) {
445- this . log . error ( `Failed to remove incomplete inline-script environment: ${ this . errorMessage ( error ) } ` ) ;
446+ this . log . error ( `Failed to remove incomplete inline-script environment: ${ getErrorMessage ( error ) } ` ) ;
446447 return false ;
447448 }
448449 }
@@ -456,10 +457,6 @@ export class InlineScriptEnvManager implements EnvironmentManager, Disposable {
456457 return compareReleaseSegments ( actualRelease , expectedRelease ) === 0 ;
457458 }
458459
459- private errorMessage ( error : unknown ) : string {
460- return error instanceof Error ? error . message : String ( error ) ;
461- }
462-
463460 dispose ( ) : void {
464461 this . _onDidChangeEnvironments . dispose ( ) ;
465462 this . _onDidChangeEnvironment . dispose ( ) ;
0 commit comments