From 3569baa6f79d3034012b1908be7384d9ca589f52 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Tue, 16 Jan 2024 14:05:55 +0100 Subject: [PATCH] Improve notebook error logging (#13256) --- .../service/notebook-kernel-history-service.ts | 12 +++++------- .../service/notebook-kernel-quick-pick-service.ts | 2 ++ .../src/plugin/notebook/notebook-kernels.ts | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/notebook/src/browser/service/notebook-kernel-history-service.ts b/packages/notebook/src/browser/service/notebook-kernel-history-service.ts index 5115820134209..70a3c79389976 100644 --- a/packages/notebook/src/browser/service/notebook-kernel-history-service.ts +++ b/packages/notebook/src/browser/service/notebook-kernel-history-service.ts @@ -48,10 +48,8 @@ export class NotebookKernelHistoryService implements Disposable { @inject(CommandService) protected commandService: CommandService; - declare serviceBrand: undefined; - - private static STORAGE_KEY = 'notebook.kernelHistory'; - private mostRecentKernelsMap: KernelsList = {}; + protected static STORAGE_KEY = 'notebook.kernelHistory'; + protected mostRecentKernelsMap: KernelsList = {}; @postConstruct() protected init(): void { @@ -97,16 +95,16 @@ export class NotebookKernelHistoryService implements Disposable { this.saveState(); } - private saveState(): void { + protected saveState(): void { let notEmpty = false; - for (const [_, kernels] of Object.entries(this.mostRecentKernelsMap)) { + for (const kernels of Object.values(this.mostRecentKernelsMap)) { notEmpty = notEmpty || Object.entries(kernels).length > 0; } this.storageService.setData(NotebookKernelHistoryService.STORAGE_KEY, notEmpty ? this.mostRecentKernelsMap : undefined); } - private async loadState(): Promise { + protected async loadState(): Promise { const kernelMap = await this.storageService.getData(NotebookKernelHistoryService.STORAGE_KEY); if (kernelMap) { this.mostRecentKernelsMap = kernelMap as KernelsList; diff --git a/packages/notebook/src/browser/service/notebook-kernel-quick-pick-service.ts b/packages/notebook/src/browser/service/notebook-kernel-quick-pick-service.ts index b1387fa7241d5..7b999993202d1 100644 --- a/packages/notebook/src/browser/service/notebook-kernel-quick-pick-service.ts +++ b/packages/notebook/src/browser/service/notebook-kernel-quick-pick-service.ts @@ -356,6 +356,7 @@ export class NotebookKernelQuickPickService { return this.displaySelectAnotherQuickPick(editor, false); } } catch (ex) { + console.error('Failed to select notebook kernel', ex); return false; } } else if (isKernelPick(selectedKernelPickItem)) { @@ -370,6 +371,7 @@ export class NotebookKernelQuickPickService { await selectedKernelPickItem.action.run(this.commandService); return true; } catch (ex) { + console.error('Failed to select notebook kernel', ex); return false; } } diff --git a/packages/plugin-ext/src/plugin/notebook/notebook-kernels.ts b/packages/plugin-ext/src/plugin/notebook/notebook-kernels.ts index f03038eabebde..9dddde9768293 100644 --- a/packages/plugin-ext/src/plugin/notebook/notebook-kernels.ts +++ b/packages/plugin-ext/src/plugin/notebook/notebook-kernels.ts @@ -334,7 +334,6 @@ export class NotebookKernelsExtImpl implements NotebookKernelsExt { await obj.controller.executeHandler.call(obj.controller, cells, document.apiNotebook, obj.controller); } catch (err) { console.error(`NotebookController[${handle}] execute cells FAILED`, err); - console.error(err); } }