Skip to content

Commit 286db43

Browse files
author
Benjamin Pasero
committed
lifecycle - more details when unload fails
1 parent 982a719 commit 286db43

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
1313
import { onUnexpectedError } from 'vs/base/common/errors';
1414
import { AbstractLifecycleService } from 'vs/platform/lifecycle/common/lifecycleService';
1515
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
16+
import Severity from 'vs/base/common/severity';
17+
import { localize } from 'vs/nls';
1618

1719
export class NativeLifecycleService extends AbstractLifecycleService {
1820

@@ -107,10 +109,7 @@ export class NativeLifecycleService extends AbstractLifecycleService {
107109
reason
108110
});
109111

110-
return handleVetos(vetos, err => {
111-
this.notificationService.error(toErrorMessage(err));
112-
onUnexpectedError(err);
113-
});
112+
return handleVetos(vetos, error => this.onShutdownError(reason, error));
114113
}
115114

116115
private async handleWillShutdown(reason: ShutdownReason): Promise<void> {
@@ -128,9 +127,34 @@ export class NativeLifecycleService extends AbstractLifecycleService {
128127
try {
129128
await Promise.all(joiners);
130129
} catch (error) {
131-
this.notificationService.error(toErrorMessage(error));
132-
onUnexpectedError(error);
130+
this.onShutdownError(reason, error);
131+
}
132+
}
133+
134+
private onShutdownError(reason: ShutdownReason, error: Error): void {
135+
let message: string;
136+
switch (reason) {
137+
case ShutdownReason.CLOSE:
138+
message = localize('errorClose', "An unexpected error prevented the window from closing ({0}).", toErrorMessage(error));
139+
break;
140+
case ShutdownReason.QUIT:
141+
message = localize('errorQuit', "An unexpected error prevented the application from closing ({0}).", toErrorMessage(error));
142+
break;
143+
case ShutdownReason.RELOAD:
144+
message = localize('errorReload', "An unexpected error prevented the window from reloading ({0}).", toErrorMessage(error));
145+
break;
146+
case ShutdownReason.LOAD:
147+
message = localize('errorLoad', "An unexpected error prevented the window from changing it's workspace ({0}).", toErrorMessage(error));
148+
break;
133149
}
150+
151+
this.notificationService.notify({
152+
severity: Severity.Error,
153+
message,
154+
sticky: true
155+
});
156+
157+
onUnexpectedError(error);
134158
}
135159
}
136160

0 commit comments

Comments
 (0)