File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export class CvmService implements ITencentCloudAPI {
2727 ( result ) => {
2828 // console.debug('[DEBUG]--------------------------------result:', result);
2929 if ( result . TotalCount === 0 ) {
30- throw new Error ( '[Warn] DescribeInstances result.TotalCount is 0.' ) ;
30+ console . warn ( '[Warn] DescribeInstances result.TotalCount is 0.' ) ;
3131 }
3232 return result . InstanceSet ;
3333 } ,
Original file line number Diff line number Diff line change @@ -21,8 +21,12 @@ export class CvmResProvider extends tencent.tree.TreeDataProvider {
2121 const service = new CvmService ( ) ;
2222 const instances = await service . describeInstances ( ) ;
2323 const config = await service . getConfig ( ) ;
24+ let items : tencent . tree . TreeItem [ ] = [ ] ;
25+ if ( ! Array . isArray ( instances ) ) {
26+ return items ; // return [] if instances nil
27+ }
2428
25- const items : tencent . tree . TreeItem [ ] = Array . isArray ( instances )
29+ items = instances . length > 0
2630 ? instances . map ( instance => ( {
2731 label : `${ instance . InstanceName } (${ instance . InstanceId } )` ,
2832 id : instance . InstanceId ,
@@ -42,12 +46,12 @@ export class CvmResProvider extends tencent.tree.TreeDataProvider {
4246 } ] ,
4347 } ,
4448 } ) )
45- : [ ] ; // return [] if instances nil
49+ : [ { label : "No instance." } ] ; // return none tips if instance is empty
4650
4751 return items ;
4852 } catch ( error ) {
4953 console . error ( '[Error]#### getChildren got a error:[%s] from CvmService. stack:%s' , error . message , error . stack ) ;
50- return error ;
54+ return [ ] ;
5155 }
5256
5357 } else {
You can’t perform that action at this time.
0 commit comments