I am aws lambda with Java to build one functionality and also integration response to handle custom mapping. here is code of lambda.
@Override
public LoginResponse handleRequest(LoginRequest request, Context ctx) {
LambdaLogger logger = ctx.getLogger();
LoginResponse response = new LoginResponse();
if (StringUtils.isNullOrEmpty(request.getUsername())) {
response.setErrorMessage("Invalid Username!!");
return response;
}
String domainName = request.getUsername().substring(request.getUsername().indexOf('@') + 1);
log.info("Domain name [{}] : ", domainName);
Item itm = findDomainName(domainName);
if(null == itm) {
response.setErrorMessage("Invalid Username!!");
throw new RuntimeException("Error Message");
}
}
so here my understanding is, when system will throw RuntimeException then aws treat this as internal server error with status code 500 and it will execute template mapping thing. But its return always 200. How we can return 500 or some other status code so that it can mapped with integration response pattern using java.
Thanks
