Skip to content

Commit d2f4e0c

Browse files
Backport PR #7710: Handle file rename errors (#7712)
Co-authored-by: Jeremy Tuloup <[email protected]>
1 parent f290a1d commit d2f4e0c

File tree

1 file changed

+16
-6
lines changed
  • packages/application-extension/src

1 file changed

+16
-6
lines changed

packages/application-extension/src/index.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ISanitizer,
1717
ISplashScreen,
1818
IToolbarWidgetRegistry,
19+
showErrorMessage,
1920
} from '@jupyterlab/apputils';
2021

2122
import { ConsolePanel } from '@jupyterlab/console';
@@ -658,14 +659,23 @@ const title: JupyterFrontEndPlugin<void> = {
658659
return;
659660
}
660661

661-
const result = await renameDialog(docManager, current.context);
662+
try {
663+
const result = await renameDialog(docManager, current.context);
662664

663-
// activate the current widget to bring the focus
664-
if (current) {
665-
current.activate();
666-
}
665+
// activate the current widget to bring the focus
666+
if (current) {
667+
current.activate();
668+
}
667669

668-
if (result === null) {
670+
if (result === null) {
671+
return;
672+
}
673+
} catch (error) {
674+
showErrorMessage(
675+
trans.__('Rename Error'),
676+
(error as Error).message ||
677+
trans.__('An error occurred while renaming the file.')
678+
);
669679
return;
670680
}
671681

0 commit comments

Comments
 (0)