use of com.formkiq.lambda.apigateway.exception.NotFoundException in project formkiq-core by formkiq.
the class AbstractApiRequestHandler method handleRequest.
@Override
public void handleRequest(final InputStream input, final OutputStream output, final Context context) throws IOException {
LambdaLogger logger = context.getLogger();
ApiGatewayRequestEvent event = getApiGatewayEvent(input, logger, getAwsServices());
ApiAuthorizer authorizer = new ApiAuthorizer(event);
try {
ApiRequestHandlerResponse object = processRequest(logger, event, authorizer);
processResponse(authorizer, event, object);
buildResponse(logger, output, object.getStatus(), object.getHeaders(), object.getResponse());
} catch (NotFoundException e) {
buildResponse(logger, output, SC_NOT_FOUND, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (TooManyRequestsException e) {
buildResponse(logger, output, SC_TOO_MANY_REQUESTS, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (BadException | InvalidConditionsException | DateTimeException e) {
buildResponse(logger, output, SC_BAD_REQUEST, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (ForbiddenException e) {
buildResponse(logger, output, SC_FORBIDDEN, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (UnauthorizedException e) {
buildResponse(logger, output, SC_UNAUTHORIZED, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (NotImplementedException e) {
buildResponse(logger, output, SC_NOT_IMPLEMENTED, Collections.emptyMap(), new ApiResponseError(e.getMessage()));
} catch (Exception e) {
logError(logger, e);
buildResponse(logger, output, SC_ERROR, Collections.emptyMap(), new ApiResponseError("Internal Server Error"));
}
}
Aggregations