Skip to content

Commit 9d9d973

Browse files
committed
Log and display errors when failing to export plot
1 parent 9c24994 commit 9d9d973

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/webviews/extension-side/plotView/rendererCommunication.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { IDisposable } from '../../../platform/common/types';
1010
import { noop } from '../../../platform/common/utils/misc';
1111
import { PlotViewHandler } from './plotViewHandler';
1212
import { IPlotSaveHandler } from './types';
13+
import { logger } from '../../../platform/logging';
14+
import { DataScience } from '../../../platform/common/utils/localize';
1315

1416
export type OpenImageInPlotViewer = {
1517
type: 'openImageInPlotViewer';
@@ -48,15 +50,20 @@ export class RendererCommunication implements IExtensionSyncActivationService, I
4850
onDidReceiveMessage: Event<{ editor: NotebookEditor; message: OpenImageInPlotViewer | SaveImageAs }>;
4951
};
5052
api.onDidReceiveMessage(
51-
({ editor, message }) => {
53+
async ({ editor, message }) => {
5254
const document = editor.notebook || window.activeNotebookEditor?.notebook;
5355
if (!document) {
5456
return;
5557
}
56-
if (message.type === 'saveImageAs') {
57-
this.plotSaveHandler.savePlot(document, message.outputId, message.mimeType).catch(noop);
58-
} else if (message.type === 'openImageInPlotViewer') {
59-
this.plotViewHandler.openPlot(document, message.outputId).catch(noop);
58+
try {
59+
if (message.type === 'saveImageAs') {
60+
await this.plotSaveHandler.savePlot(document, message.outputId, message.mimeType);
61+
} else if (message.type === 'openImageInPlotViewer') {
62+
await this.plotViewHandler.openPlot(document, message.outputId);
63+
}
64+
} catch (ex) {
65+
logger.error(ex);
66+
window.showErrorMessage(DataScience.exportImageFailed(ex)).then(noop, noop);
6067
}
6168
},
6269
this,

0 commit comments

Comments
 (0)