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 {
27
27
( result ) => {
28
28
// console.debug('[DEBUG]--------------------------------result:', result);
29
29
if ( result . TotalCount === 0 ) {
30
- throw new Error ( '[Warn] DescribeInstances result.TotalCount is 0.' ) ;
30
+ console . warn ( '[Warn] DescribeInstances result.TotalCount is 0.' ) ;
31
31
}
32
32
return result . InstanceSet ;
33
33
} ,
Original file line number Diff line number Diff line change @@ -21,8 +21,12 @@ export class CvmResProvider extends tencent.tree.TreeDataProvider {
21
21
const service = new CvmService ( ) ;
22
22
const instances = await service . describeInstances ( ) ;
23
23
const config = await service . getConfig ( ) ;
24
+ let items : tencent . tree . TreeItem [ ] = [ ] ;
25
+ if ( ! Array . isArray ( instances ) ) {
26
+ return items ; // return [] if instances nil
27
+ }
24
28
25
- const items : tencent . tree . TreeItem [ ] = Array . isArray ( instances )
29
+ items = instances . length > 0
26
30
? instances . map ( instance => ( {
27
31
label : `${ instance . InstanceName } (${ instance . InstanceId } )` ,
28
32
id : instance . InstanceId ,
@@ -42,12 +46,12 @@ export class CvmResProvider extends tencent.tree.TreeDataProvider {
42
46
} ] ,
43
47
} ,
44
48
} ) )
45
- : [ ] ; // return [] if instances nil
49
+ : [ { label : "No instance." } ] ; // return none tips if instance is empty
46
50
47
51
return items ;
48
52
} catch ( error ) {
49
53
console . error ( '[Error]#### getChildren got a error:[%s] from CvmService. stack:%s' , error . message , error . stack ) ;
50
- return error ;
54
+ return [ ] ;
51
55
}
52
56
53
57
} else {
You can’t perform that action at this time.
0 commit comments