Search in sources :

Example 1 with NotImplementedException

use of com.formkiq.lambda.apigateway.exception.NotImplementedException 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"));
    }
}
Also used : ForbiddenException(com.formkiq.lambda.apigateway.exception.ForbiddenException) NotImplementedException(com.formkiq.lambda.apigateway.exception.NotImplementedException) NotFoundException(com.formkiq.lambda.apigateway.exception.NotFoundException) BadException(com.formkiq.lambda.apigateway.exception.BadException) ForbiddenException(com.formkiq.lambda.apigateway.exception.ForbiddenException) NotImplementedException(com.formkiq.lambda.apigateway.exception.NotImplementedException) DateTimeException(java.time.DateTimeException) UnauthorizedException(com.formkiq.lambda.apigateway.exception.UnauthorizedException) IOException(java.io.IOException) NotFoundException(com.formkiq.lambda.apigateway.exception.NotFoundException) BadException(com.formkiq.lambda.apigateway.exception.BadException) TooManyRequestsException(com.formkiq.lambda.apigateway.exception.TooManyRequestsException) InvalidConditionsException(com.formkiq.stacks.dynamodb.InvalidConditionsException) TooManyRequestsException(com.formkiq.lambda.apigateway.exception.TooManyRequestsException) InvalidConditionsException(com.formkiq.stacks.dynamodb.InvalidConditionsException) DateTimeException(java.time.DateTimeException) UnauthorizedException(com.formkiq.lambda.apigateway.exception.UnauthorizedException) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Aggregations

LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)1 BadException (com.formkiq.lambda.apigateway.exception.BadException)1 ForbiddenException (com.formkiq.lambda.apigateway.exception.ForbiddenException)1 NotFoundException (com.formkiq.lambda.apigateway.exception.NotFoundException)1 NotImplementedException (com.formkiq.lambda.apigateway.exception.NotImplementedException)1 TooManyRequestsException (com.formkiq.lambda.apigateway.exception.TooManyRequestsException)1 UnauthorizedException (com.formkiq.lambda.apigateway.exception.UnauthorizedException)1 InvalidConditionsException (com.formkiq.stacks.dynamodb.InvalidConditionsException)1 IOException (java.io.IOException)1 DateTimeException (java.time.DateTimeException)1