Skip to content

Commit 1e9f468

Browse files
committed
Do not fail to activate extension when watcher installation fails
This PR fixes #2184. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent c1baa42 commit 1e9f468

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/explorer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ export class OpenShiftExplorer implements TreeDataProvider<OpenShiftObject>, Dis
5252
} catch (err) {
5353
// ignore config loading error and let odo report it on first call
5454
}
55-
this.fsw = WatchUtil.watchFileForContextChange(kubeConfigFolder, 'config');
56-
this.fsw.emitter.on('file-changed', () => {
55+
try {
56+
this.fsw = WatchUtil.watchFileForContextChange(kubeConfigFolder, 'config');
57+
} catch (err) {
58+
window.showWarningMessage('Couldn\'t install watcher for Kubernetes configuration file. OpenShift Application Explorer view won\'t be updated automatically.');
59+
}
60+
this.fsw?.emitter?.on('file-changed', () => {
5761
const ku2 = new KubeConfigUtils();
5862
const newCtx = ku2.getContextObject(ku2.currentContext);
5963
if (!this.kubeContext
@@ -107,7 +111,7 @@ export class OpenShiftExplorer implements TreeDataProvider<OpenShiftObject>, Dis
107111
}
108112

109113
dispose(): void {
110-
this.fsw.watcher.close();
114+
this?.fsw.watcher.close();
111115
this.treeView.dispose();
112116
}
113117

0 commit comments

Comments
 (0)