【发布时间】:2022-09-28 21:48:29
【问题描述】:
我想在我的 lambda 函数上发生内部服务器错误 ( 5xx/500 ) 事件时测试我的代码功能和错误日志。
我不想使用 localstack 或一些模拟库在本地执行此操作,我想在 AWS 上部署的 lambda 函数上尝试此操作。
更新 :-事件类型为APIGatewayProxyEvent
处理事件的函数:-
functionFind = async (
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
try {
this.loggingLambdaEvent(event)
const request = new functionRequest(event)
await ValidationHelper.validateOrReject(request)
const useCaseOutput = await this.useCase.execute(request)
return new functionResponseBuilder(useCaseOutput).serialize()
} catch (error) {
if (
error instanceof InvalidRequestParameter ||
error instanceof AccountInvalidParameter
) {
return new BadRequestResponse(error).serialize()
} else if (
error instanceof AccountIdNotFound ||
error instanceof AccountInvalidToken
) {
return new functionAndBearerTokenUnauthorizedResponse(
error
).serialize()
} else {
return new InternalServerErrorResponse(error).serialize()
}
}
}
有没有办法这样做?
标签: typescript amazon-web-services aws-lambda aws-serverless