Skip to content

Commit

Permalink
fix: raise exception when info 404
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Jul 30, 2024
1 parent b9e45d7 commit a0a0432
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 57 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635756716877_20211101085157044368.png)

<p align="center" class="flex justify-center">
<a href="https://nodejs.org/en/" class="ml-1" target="_blank">
<img src="https://img.shields.io/badge/node-%3E%3D%2014.14.0-brightgreen" alt="node.js version">
Expand Down
70 changes: 15 additions & 55 deletions src/subCommands/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,15 @@ export default class Info {
}

async getFunction(): Promise<{ error: any } | any> {
try {
return await this.fcSdk.getFunction(this.functionName, this.getApiType);
} catch (ex) {
logger.debug(`Get function ${this.functionName} error: ${ex}`);
return {
error: {
code: ex.code,
message: ex.message,
},
};
}
return await this.fcSdk.getFunction(this.functionName, this.getApiType);
}

async getTriggers(): Promise<any[]> {
const result: any[] = [];
for (const triggerName of this.triggersName) {
try {
// eslint-disable-next-line no-await-in-loop
const config = await this.fcSdk.getTrigger(this.functionName, triggerName, this.getApiType);
result.push(config);
} catch (ex) {
logger.debug(`Get trigger ${this.functionName}/${triggerName} error: ${ex}`);
result.push({
error: {
code: ex.code,
message: ex.message,
},
});
}
// eslint-disable-next-line no-await-in-loop
const config = await this.fcSdk.getTrigger(this.functionName, triggerName, this.getApiType);
result.push(config);
}
return result;
}
Expand All @@ -115,43 +95,23 @@ export default class Info {
if (!this.inputs.props.asyncInvokeConfig) {
return {};
}
try {
const asyncInvokeConfig = _.get(this.inputs, 'props.asyncInvokeConfig', {});
const qualifier = _.get(asyncInvokeConfig, 'qualifier', 'LATEST');
const result = await this.fcSdk.getAsyncInvokeConfig(
this.functionName,
qualifier,
this.getApiType,
);
if (result) {
result.qualifier = qualifier;
}
return result;
} catch (ex) {
logger.debug(`Get AsyncInvokeConfig ${this.functionName} error: ${ex}`);
return {
error: {
code: ex.code,
message: ex.message,
},
};
const asyncInvokeConfig = _.get(this.inputs, 'props.asyncInvokeConfig', {});
const qualifier = _.get(asyncInvokeConfig, 'qualifier', 'LATEST');
const result = await this.fcSdk.getAsyncInvokeConfig(
this.functionName,
qualifier,
this.getApiType,
);
if (result) {
result.qualifier = qualifier;
}
return result;
}

async getVpcBing(): Promise<any> {
if (!this.inputs.props.vpcBinding) {
return {};
}
try {
return await this.fcSdk.getVpcBinding(this.functionName, this.getApiType);
} catch (ex) {
logger.debug(`Get VpcBinding ${this.functionName} error: ${ex}`);
return {
error: {
code: ex.code,
message: ex.message,
},
};
}
return await this.fcSdk.getVpcBinding(this.functionName, this.getApiType);
}
}

0 comments on commit a0a0432

Please sign in to comment.