Skip to content

Commit 5d555d3

Browse files
committed
fix: add can not get CIDR error
1 parent 44060f6 commit 5d555d3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/vpc.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { ApiTypeError } = require('tencent-component-toolkit/lib/utils/error')
2+
13
/**
24
* 自然数级别的区间计算库;也可用于字符串区间(直接使用字符串对比),但此时不支持区间减法。
35
* nature number ranges calculate library, also support string ranges without subtraction.
@@ -232,8 +234,10 @@ function getAvailableCidr(
232234
})
233235

234236
const [avalableZone] = totalRang.ranges
235-
236-
return `${uintToIp(avalableZone[0])}/29`
237+
if (avalableZone) {
238+
return `${uintToIp(avalableZone[0])}/29`
239+
}
240+
throw new ApiTypeError(`GET_AVAILABLE_CIDR`, `Can not get available CIDR for VPC ${vpcCIDR}.`)
237241
}
238242

239243
module.exports = {

0 commit comments

Comments
 (0)