Skip to content

Commit 13ea009

Browse files
authored
Ignore errors when accessing shell info using VSC API (microsoft#6641)
* Ignore errors * Use simple try catch * Ooops
1 parent 759efd6 commit 13ea009

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/client/common/application/applicationEnvironment.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { inject, injectable } from 'inversify';
77
import * as path from 'path';
88
import { parse } from 'semver';
99
import * as vscode from 'vscode';
10+
import { traceError } from '../logger';
1011
import { IPlatformService } from '../platform/types';
1112
import { ICurrentProcess, IPathUtils } from '../types';
1213
import { OSType } from '../utils/platform';
@@ -50,9 +51,22 @@ export class ApplicationEnvironment implements IApplicationEnvironment {
5051
// tslint:disable-next-line:non-literal-require
5152
return this.packageJson.displayName;
5253
}
54+
/**
55+
* At the time of writing this API, the vscode.env.shell isn't officially released in stable version of VS Code.
56+
* Using this in stable version seems to throw errors in VSC with messages being displayed to the user about use of
57+
* unstable API.
58+
* Solution - log and suppress the errors.
59+
* @readonly
60+
* @type {(string | undefined)}
61+
* @memberof ApplicationEnvironment
62+
*/
5363
public get shell(): string | undefined {
54-
// tslint:disable-next-line:no-any
55-
return (vscode.env as any).shell;
64+
try {
65+
// tslint:disable-next-line:no-any
66+
return (vscode.env as any).shell;
67+
} catch (error) {
68+
traceError('Unable to determine shell using VS Code API.', error);
69+
}
5670
}
5771
// tslint:disable-next-line:no-any
5872
public get packageJson(): any {

0 commit comments

Comments
 (0)