Skip to content

Commit

Permalink
add alert if config cannot be opened from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MFA-X-AI committed Sep 5, 2024
1 parent 03cdc5e commit c62eef4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,20 @@ const xircuits: JupyterFrontEndPlugin<void> = {
icon: xircuitsIcon,
execute: async () => {
const configPath = `.xircuits/config.ini`;
await docmanager.openOrReveal(configPath);
try {
// Check if the file exists first
await app.serviceManager.contents.get(configPath);
// If we reach here, the file exists, so we can try to open it
await docmanager.openOrReveal(configPath);
} catch (error) {
if (error.response && error.response.status === 404) {
alert('Xircuits configuration file not found. Check if it exists or enable hidden files when you launch Jupyter Lab.');
} else {
alert(`Error accessing Xircuits configuration: ${error.message}`);
}
}
}
);
});

mainMenu.settingsMenu.addGroup([
{
Expand Down

0 comments on commit c62eef4

Please sign in to comment.