public final Response handleRequest()

in powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/AbstractCustomResourceHandler.java [51:76]


    public final Response handleRequest(CloudFormationCustomResourceEvent event, Context context) {
        String responseUrl = Objects.requireNonNull(event.getResponseUrl(),
                "Event must have a non-null responseUrl to be able to send the response.");

        CloudFormationResponse client = buildResponseClient();

        Response response = null;
        try {
            response = getResponse(event, context);
            LOG.debug("Preparing to send response {} to {}.", response, responseUrl);
            client.send(event, context, response);
        } catch (IOException ioe) {
            LOG.error("Unable to send response {} to {}.", response, responseUrl, ioe);
            onSendFailure(event, context, response, ioe);
        } catch (CustomResourceResponseException rse) {
            LOG.error("Unable to generate response. Sending empty failure to {}", responseUrl, rse);
            try {
                client.send(event, context, Response.failed());
            } catch (Exception e) {
                // unable to generate response AND send the failure
                LOG.error("Unable to send failure response to {}.", responseUrl, e);
                onSendFailure(event, context, null, e);
            }
        }
        return response;
    }