Skip to content

Commit 8e400d0

Browse files
committed
fix: remove command exit code is 0 when 404
1 parent 292751a commit 8e400d0

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/impl/domain.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,29 @@ export class Domain {
176176
await this.customDomain.tryHandleAutoDomain();
177177
const logger = GLogger.getLogger();
178178
const domainName = await this.getDomainName();
179-
logger.write(`Remove custom domain: ${this.region}/${domainName}`);
179+
const region = this.region;
180+
logger.write(`Remove custom domain: ${region}/${domainName}`);
180181
console.log();
181182
const client = this.getFcClient('remove');
182183
if (this.yes) {
183-
await client.deleteCustomDomain(domainName);
184-
logger.debug(`delete custom domain ${this.region}/${domainName} success`);
184+
await delCustomDomain();
185185
return;
186186
}
187187
const msg = `Do you want to delete this custom domain ${this.region}/${domainName}`;
188188
if (await promptForConfirmOrDetails(msg)) {
189-
await client.deleteCustomDomain(domainName);
190-
logger.debug(`delete custom domain ${this.region}/${domainName} success`);
189+
await delCustomDomain();
190+
}
191+
192+
async function delCustomDomain() {
193+
try {
194+
await client.deleteCustomDomain(domainName);
195+
logger.debug(`delete custom domain ${region}/${domainName} success`);
196+
} catch (error) {
197+
logger.error(`delete custom domain error: ${error}`);
198+
if (error.code !== 'DomainNameNotFound' || error.statusCode !== 404) {
199+
throw error;
200+
}
201+
}
191202
}
192203
}
193204

0 commit comments

Comments
 (0)