@Test public void streamHandle_InvalidRequestEventException_responseString() throws IOException { ByteArrayOutputStream respStream = new ByteArrayOutputStream(); exceptionHandler.handle(new InvalidRequestEventException(INVALID_REQUEST_MESSAGE, null), respStream); assertNotNull(respStream); assertTrue(respStream.size() > 0); AwsProxyResponse resp = objectMapper.readValue(new ByteArrayInputStream(respStream.toByteArray()), AwsProxyResponse.class); assertNotNull(resp); String body = objectMapper.writeValueAsString(new ErrorModel(AwsProxyExceptionHandler.INTERNAL_SERVER_ERROR)); assertEquals(body, resp.getBody()); }
@Override public AwsProxyResponse handle(Throwable ex) { log.error("Called exception handler for:", ex); ex.printStackTrace(); if (ex instanceof InvalidRequestEventException || ex instanceof InternalServerErrorException) { return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR)); } else { return new AwsProxyResponse(502, headers, getErrorJson(GATEWAY_TIMEOUT_ERROR)); } }
AwsProxyExceptionHandler implements ExceptionHandler<AwsProxyResponse> { @Override public AwsProxyResponse handle(Throwable ex) { log.error("Called exception handler for:", ex); ex.printStackTrace(); if (ex instanceof InvalidRequestEventException || ex instanceof InternalServerErrorException) { return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR)); } else { return new AwsProxyResponse(502, headers, getErrorJson(GATEWAY_TIMEOUT_ERROR)); } } }
AwsProxyExceptionHandler implements ExceptionHandler<AwsProxyResponse> { @Override public AwsProxyResponse handle(Throwable ex) { log.error("Called exception handler for:", ex); ex.printStackTrace(); if (ex instanceof InvalidRequestEventException || ex instanceof InternalServerErrorException) { return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR)); } else { return new AwsProxyResponse(502, headers, getErrorJson(GATEWAY_TIMEOUT_ERROR)); } }  }
AwsProxyExceptionHandler implements ExceptionHandler<AwsProxyResponse> { @Override public AwsProxyResponse handle(Throwable ex) { log.error("Called exception handler for:", ex); ex.printStackTrace(); if (ex instanceof InvalidRequestEventException || ex instanceof InternalServerErrorException) { return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR)); } else { return new AwsProxyResponse(502, headers, getErrorJson(GATEWAY_TIMEOUT_ERROR)); } }  @Override AwsProxyResponse handle(Throwable ex); @Override void handle(Throwable ex, OutputStream stream); }
AwsProxyExceptionHandler implements ExceptionHandler<AwsProxyResponse> { @Override public AwsProxyResponse handle(Throwable ex) { log.error("Called exception handler for:", ex); ex.printStackTrace(); if (ex instanceof InvalidRequestEventException || ex instanceof InternalServerErrorException) { return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR)); } else { return new AwsProxyResponse(502, headers, getErrorJson(GATEWAY_TIMEOUT_ERROR)); } }  @Override AwsProxyResponse handle(Throwable ex); @Override void handle(Throwable ex, OutputStream stream);  }