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
preguntada hace 4 años802 visualizaciones
3 Respuestas
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
respondido hace 4 años
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
respondido hace 4 años
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
respondido hace 4 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas