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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠