Skip to content

Commit

Permalink
Split up getEnvironment() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jul 29, 2020
1 parent 15e410b commit 588bc01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -42,7 +42,11 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I

abstract getConnection(): IRemoteAgentConnection | null;

getEnvironment(bail?: boolean): Promise<IRemoteAgentEnvironment | null> {
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
return this.getRawEnvironment().then(undefined, () => null);
}

getRawEnvironment(): Promise<IRemoteAgentEnvironment | null> {
if (!this._environment) {
this._environment = this._withChannel(
async (channel, connection) => {
Expand All @@ -53,7 +57,7 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I
null
);
}
return bail ? this._environment : this._environment.then(undefined, () => null);
return this._environment;
}

getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> {
Expand Down Expand Up @@ -170,7 +174,7 @@ class RemoteConnectionFailureNotificationContribution implements IWorkbenchContr
@INotificationService notificationService: INotificationService,
) {
// Let's cover the case where connecting to fetch the remote extension info fails
remoteAgentService.getEnvironment(true)
remoteAgentService.getRawEnvironment()
.then(undefined, err => {
if (!RemoteAuthorityResolverError.isHandled(err)) {
notificationService.error(nls.localize('connectionError', "Failed to connect to the remote extension host server (Error: {0})", err ? err.message : ''));
Expand Down
Expand Up @@ -21,7 +21,14 @@ export interface IRemoteAgentService {
readonly socketFactory: ISocketFactory;

getConnection(): IRemoteAgentConnection | null;
getEnvironment(bail?: boolean): Promise<IRemoteAgentEnvironment | null>;
/**
* Get the remote environment. In case of an error, returns `null`.
*/
getEnvironment(): Promise<IRemoteAgentEnvironment | null>;
/**
* Get the remote environment. Can return an error.
*/
getRawEnvironment(): Promise<IRemoteAgentEnvironment | null>;
getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined>;
disableTelemetry(): Promise<void>;
logTelemetry(eventName: string, data?: ITelemetryData): Promise<void>;
Expand Down

0 comments on commit 588bc01

Please sign in to comment.