Skip to content

Commit aecade1

Browse files
committed
Display message when server extension unavailable
1 parent e7cc1ca commit aecade1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/model.ts

Lines changed: 18 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,20 @@ 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+
'Required Git serverextension not available.'
1027+
);
1028+
}
10171029
const data = await response.json();
10181030
return data['server_root'];
1019-
} catch (reason) {
1020-
throw new Error(reason);
1031+
} catch (error) {
1032+
if (error instanceof ServerConnection.ResponseError) {
1033+
throw error;
1034+
} else {
1035+
throw new Error(error);
1036+
}
10211037
}
10221038
}
10231039

0 commit comments

Comments
 (0)