Lambda error code

0

Is there anyway to control Lambda error code? For example, in case I have exception, for some cases I want to put the error code value as 412 and not 200 as it now

asafha
質問済み 4年前802ビュー
3回答
0

If you mean for use with apigateway, you need to return a specifically formatted response.

{
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "multiValueHeaders": { "headerName": ["headerValue", "headerValue2", ...], ... },
    "body": "..."
}

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format

Ellison
回答済み 4年前
0

I'm not using API gateway. I trigger Lamda using S3, and in case of error, i'm using DLQ. In DLQ message there is an attribute ErrorCode which the value is always is 200, but I want to customize this code as part of my Lambda code to publish different code for different errors

asafha
回答済み 4年前
0

Ah, I see. No, that is not possible. That field is for the code that would have been returned by invoke if it were synchronous, which should be 200 most of the time, even in the case of exceptions in the user controlled lambda code. The possible values are here: https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_Errors

Ellison
回答済み 4年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ