提交 d3da6f47 编写于 作者: M Martin Aeschlimann

Remote: seeing an error message when not having remote extension installed. Fixes #91526

上级 c2d241d9
......@@ -40,28 +40,24 @@ export enum RemoteAuthorityResolverErrorCode {
export class RemoteAuthorityResolverError extends Error {
public static isHandledNotAvailable(err: any): boolean {
if (err instanceof RemoteAuthorityResolverError) {
if (err._code === RemoteAuthorityResolverErrorCode.NotAvailable && err._detail === true) {
return true;
}
}
return this.isTemporarilyNotAvailable(err);
}
public static isTemporarilyNotAvailable(err: any): boolean {
return (err instanceof RemoteAuthorityResolverError) && err._code === RemoteAuthorityResolverErrorCode.TemporarilyNotAvailable;
}
public static isNoResolverFound(err: any): boolean {
public static isNoResolverFound(err: any): err is RemoteAuthorityResolverError {
return (err instanceof RemoteAuthorityResolverError) && err._code === RemoteAuthorityResolverErrorCode.NoResolverFound;
}
public static isHandled(err: any): boolean {
return (err instanceof RemoteAuthorityResolverError) && err.isHandled;
}
public readonly _message: string | undefined;
public readonly _code: RemoteAuthorityResolverErrorCode;
public readonly _detail: any;
public isHandled: boolean;
constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) {
super(message);
......@@ -69,6 +65,8 @@ export class RemoteAuthorityResolverError extends Error {
this._code = code;
this._detail = detail;
this.isHandled = (code === RemoteAuthorityResolverErrorCode.NotAvailable) && detail === true;
// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
if (typeof (<any>Object).setPrototypeOf === 'function') {
......
......@@ -459,16 +459,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
} catch (err) {
const remoteName = getRemoteName(remoteAuthority);
if (RemoteAuthorityResolverError.isNoResolverFound(err)) {
this._handleNoResolverFound(remoteName, allExtensions);
err.isHandled = await this._handleNoResolverFound(remoteName, allExtensions);
} else {
console.log(err);
if (RemoteAuthorityResolverError.isHandledNotAvailable(err)) {
console.log(`Not showing a notification for the error`);
} else {
this._notificationService.notify({ severity: Severity.Error, message: nls.localize('resolveAuthorityFailure', "Resolving the authority `{0}` failed", remoteName) });
if (RemoteAuthorityResolverError.isHandled(err)) {
console.log(`Error handled: Not showing a notification for the error`);
}
}
this._remoteAuthorityResolverService.setResolvedAuthorityError(remoteAuthority, err);
// Proceed with the local extension host
......@@ -584,10 +581,10 @@ export class ExtensionService extends AbstractExtensionService implements IExten
}
}
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<void> {
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<boolean> {
const recommendation = this._productService.remoteExtensionTips?.[remoteName];
if (!recommendation) {
return;
return false;
}
const sendTelemetry = (userReaction: 'install' | 'enable' | 'cancel') => {
/* __GDPR__
......@@ -641,6 +638,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
);
}
return true;
}
}
......
......@@ -164,7 +164,7 @@ class RemoteConnectionFailureNotificationContribution implements IWorkbenchContr
// Let's cover the case where connecting to fetch the remote extension info fails
remoteAgentService.getEnvironment(true)
.then(undefined, err => {
if (!RemoteAuthorityResolverError.isHandledNotAvailable(err)) {
if (!RemoteAuthorityResolverError.isHandled(err)) {
notificationService.error(nls.localize('connectionError', "Failed to connect to the remote extension host server (Error: {0})", err ? err.message : ''));
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册