From 36fe725cf0ec3cf2864917f4e29b7efee7ea844a Mon Sep 17 00:00:00 2001 From: Kevin Cunnane Date: Tue, 18 Jun 2019 16:19:32 -0700 Subject: [PATCH] Fix RunAllCells throwing unhandled exception (#6089) - Added await here. - There's a 2nd entry point already doing it the right way, in the Notebook extension. No need to change that --- .../parts/notebook/notebook.component.ts | 2 +- .../parts/notebook/notebookActions.ts | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sql/workbench/parts/notebook/notebook.component.ts b/src/sql/workbench/parts/notebook/notebook.component.ts index 170b550b75..c35502838c 100644 --- a/src/sql/workbench/parts/notebook/notebook.component.ts +++ b/src/sql/workbench/parts/notebook/notebook.component.ts @@ -407,7 +407,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe let addTextCellButton = new AddCellAction('notebook.AddTextCell', localize('text', "Text"), 'notebook-button icon-add'); addTextCellButton.cellType = CellTypes.Markdown; - this._runAllCellsAction = new RunAllCellsAction('notebook.runAllCells', localize('runAll', "Run Cells"), 'notebook-button icon-run-cells'); + this._runAllCellsAction = this.instantiationService.createInstance(RunAllCellsAction, 'notebook.runAllCells', localize('runAll', "Run Cells"), 'notebook-button icon-run-cells'); let clearResultsButton = new ClearAllOutputsAction('notebook.ClearAllOutputs', localize('clearResults', "Clear Results"), 'notebook-button icon-clear-results'); this._trustedAction = this.instantiationService.createInstance(TrustedAction, 'notebook.Trusted'); diff --git a/src/sql/workbench/parts/notebook/notebookActions.ts b/src/sql/workbench/parts/notebook/notebookActions.ts index 21669ab508..e1304eec44 100644 --- a/src/sql/workbench/parts/notebook/notebookActions.ts +++ b/src/sql/workbench/parts/notebook/notebookActions.ts @@ -252,19 +252,19 @@ export class TrustedAction extends ToggleableAction { // Action to run all code cells in a notebook. export class RunAllCellsAction extends Action { constructor( - id: string, label: string, cssClass: string + id: string, label: string, cssClass: string, + @INotificationService private notificationService: INotificationService ) { super(id, label, cssClass); } - public run(context: NotebookComponent): Promise { - return new Promise((resolve, reject) => { - try { - context.runAllCells(); - resolve(true); - } catch (e) { - reject(e); - } - }); + public async run(context: NotebookComponent): Promise { + try { + await context.runAllCells(); + return true; + } catch (e) { + this.notificationService.error(getErrorMessage(e)); + return false; + } } }