@@ -10,6 +10,8 @@ import { IDisposable } from '../../../platform/common/types';
10
10
import { noop } from '../../../platform/common/utils/misc' ;
11
11
import { PlotViewHandler } from './plotViewHandler' ;
12
12
import { IPlotSaveHandler } from './types' ;
13
+ import { logger } from '../../../platform/logging' ;
14
+ import { DataScience } from '../../../platform/common/utils/localize' ;
13
15
14
16
export type OpenImageInPlotViewer = {
15
17
type : 'openImageInPlotViewer' ;
@@ -48,15 +50,20 @@ export class RendererCommunication implements IExtensionSyncActivationService, I
48
50
onDidReceiveMessage : Event < { editor : NotebookEditor ; message : OpenImageInPlotViewer | SaveImageAs } > ;
49
51
} ;
50
52
api . onDidReceiveMessage (
51
- ( { editor, message } ) => {
53
+ async ( { editor, message } ) => {
52
54
const document = editor . notebook || window . activeNotebookEditor ?. notebook ;
53
55
if ( ! document ) {
54
56
return ;
55
57
}
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 ) ;
60
67
}
61
68
} ,
62
69
this ,
0 commit comments