Skip to content

Commit e1fb6a3

Browse files
authored
Merge pull request #569 from lresende/fix-git-serverextension-not-available
Display message when server extension unavailable
2 parents e7cc1ca + 1c36251 commit e1fb6a3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/model.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ISignal, Signal } from '@phosphor/signaling';
1212
import { httpGitRequest } from './git';
1313
import { IGitExtension, Git } from './tokens';
1414
import { decodeStage } from './utils';
15+
import { Dialog, showErrorMessage } from '@jupyterlab/apputils';
1516

1617
// Default refresh interval (in milliseconds) for polling the current Git status (NOTE: this value should be the same value as in the plugin settings schema):
1718
const DEFAULT_REFRESH_INTERVAL = 3000; // ms
@@ -33,6 +34,11 @@ export class GitExtension implements IGitExtension {
3334
})
3435
.catch(reason => {
3536
console.error(`Fail to get the server root path.\n${reason}`);
37+
showErrorMessage(
38+
'Internal Error:',
39+
`Fail to get the server root path.\n\n${reason}`,
40+
[Dialog.warnButton({ label: 'DISMISS' })]
41+
);
3642
});
3743

3844
let interval: number;
@@ -1014,10 +1020,22 @@ export class GitExtension implements IGitExtension {
10141020
private async _getServerRoot(): Promise<string> {
10151021
try {
10161022
const response = await httpGitRequest('/git/server_root', 'GET', null);
1023+
if (response.status === 404) {
1024+
throw new ServerConnection.ResponseError(
1025+
response,
1026+
'Git server extension is unavailable. Please ensure you have installed the ' +
1027+
'JupyterLab Git server extension by running: pip install --upgrade jupyterlab-git. ' +
1028+
'To confirm that the server extension is installed, run: jupyter serverextension list.'
1029+
);
1030+
}
10171031
const data = await response.json();
10181032
return data['server_root'];
1019-
} catch (reason) {
1020-
throw new Error(reason);
1033+
} catch (error) {
1034+
if (error instanceof ServerConnection.ResponseError) {
1035+
throw error;
1036+
} else {
1037+
throw new Error(error);
1038+
}
10211039
}
10221040
}
10231041

0 commit comments

Comments
 (0)