Quarkus ExceptionMapper is not called for AWS lambda RequestHandler. How to fix it?

39 Views Asked by At

I have a quarkus AWS lambda handler

public class Handler implements RequestHandler<RequestDto, ResponseDto> {

    @Override
    public ResponseDto handleRequest(final RequestDto request, final Context context) {
    ...
     //here for example a custom exception is thrown
     throw new CustomException("some error message");
    ...
    }

}

I have also an exception mapper for CustomException

@Provider
@RegisterForReflection
public class CustomExceptionMapper implements ExceptionMapper<CustomException> {

 

    @Override
    public Response toResponse(CustomException ex) {
        var response = ...;
        return Response.status(HttpStatus.SC_OK).entity(response).build();
    }

The issue is that the CustomExceptionMapper is not called when the AWS hadnler is called an exception is thrown.

How to resolve this?

Tries annotations @Provider @RegisterForReflection

0

There are 0 best solutions below