refactor(AWS Deploy): Minimize try/catch wrap

This commit is contained in:
Mariusz Nowak 2021-03-11 14:17:35 +01:00 committed by Mariusz Nowak
parent 6537a5e48d
commit a7d2cf0605

View File

@ -67,20 +67,21 @@ class AwsDeployFunction {
FunctionName: this.options.functionObj.name,
};
try {
const result = await this.provider.request('Lambda', 'getFunction', params);
const result = await (async () => {
try {
return await this.provider.request('Lambda', 'getFunction', params);
} catch (error) {
const errorMessage = [
`The function "${this.options.function}" you want to update is not yet deployed.`,
' Please run "serverless deploy" to deploy your service.',
' After that you can redeploy your services functions with the',
' "serverless deploy function" command.',
].join('');
throw new ServerlessError(errorMessage);
}
})();
this.serverless.service.provider.remoteFunctionData = result;
return result;
} catch {
const errorMessage = [
`The function "${this.options.function}" you want to update is not yet deployed.`,
' Please run "serverless deploy" to deploy your service.',
' After that you can redeploy your services functions with the',
' "serverless deploy function" command.',
].join('');
throw new ServerlessError(errorMessage);
}
if (result) this.serverless.service.provider.remoteFunctionData = result;
}
checkIfFunctionChangesBetweenImageAndHandler() {