Skip to content

Commit

Permalink
Wrap context.save inside try-catch block (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Aug 31, 2022
1 parent 249b077 commit c9c6db5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions packages/jupyterlab-preview/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
let context: DocumentRegistry.IContext<INotebookModel>;
if (current) {
context = current.context;
await context.save();

try {
await context.save();
} catch (e) {
console.error(e);
}
commands.execute('docmanager:open', {
path: context.path,
factory: 'Voila-preview',
Expand All @@ -204,7 +207,11 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
if (!current) {
return;
}
await current.context.save();
try {
await current.context.save();
} catch (e) {
console.error(e);
}
const voilaUrl = getVoilaUrl(current.context.path);
window.open(voilaUrl);
},
Expand Down
6 changes: 5 additions & 1 deletion packages/jupyterlab-preview/src/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ export class VoilaPreview extends DocumentWidget<IFrame, INotebookModel> {
icon: refreshIcon,
tooltip: 'Reload Preview',
onClick: async () => {
await context.save();
try {
await context.save();
} catch (e) {
console.error(e);
}
this.reload();
}
});
Expand Down

0 comments on commit c9c6db5

Please sign in to comment.