@@ -183,8 +183,26 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
183183 . then ( result => ( allTrue ( result ) ? `${ contextValue } .can-delete` : contextValue ) ) ;
184184 }
185185
186+
186187 // eslint-disable-next-line class-methods-use-this
187188 async getTreeItem ( element : ExplorerItem ) : Promise < TreeItem > {
189+ try {
190+ return await this . _getTreeItem ( element ) ;
191+ } catch ( err ) {
192+ // eslint-disable-next-line no-console
193+ console . error ( 'getTreeItem failed:' , err , element ) ;
194+
195+ return {
196+ label : '⚠️ Broken item' ,
197+ tooltip : `${ err } ` ,
198+ iconPath : new ThemeIcon ( 'error' ) ,
199+ collapsibleState : TreeItemCollapsibleState . None
200+ } ;
201+ }
202+ }
203+
204+ // eslint-disable-next-line class-methods-use-this
205+ async _getTreeItem ( element : ExplorerItem ) : Promise < TreeItem > {
188206 if ( 'command' in element || ( 'label' in element && 'iconPath' in element ) ) {
189207 return element ;
190208 }
@@ -474,7 +492,23 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
474492 }
475493
476494 // eslint-disable-next-line class-methods-use-this
495+
477496 async getChildren ( element ?: ExplorerItem ) : Promise < ExplorerItem [ ] > {
497+ try {
498+ return await this . _getChildren ( element ) ;
499+ } catch ( err ) {
500+ // eslint-disable-next-line no-console
501+ console . error ( 'getChildren failed:' , err ) ;
502+
503+ return [ {
504+ label : '⚠️ Error loading tree' ,
505+ tooltip : String ( err ) ,
506+ iconPath : new ThemeIcon ( 'error' )
507+ } ] ;
508+ }
509+ }
510+
511+ async _getChildren ( element ?: ExplorerItem ) : Promise < ExplorerItem [ ] > {
478512 let result : ExplorerItem [ ] = [ ] ;
479513 // don't show Open In Developer Dashboard if not openshift cluster
480514 const isOpenshiftCluster = await isOpenShiftCluster ( this . executionContext ) ;
0 commit comments