JobExceptionHandlerImpl implements JobExceptionHandler { @Override public void onException(Exception e, Map<String, String> context) { if (e instanceof AmazonServiceException) { final AmazonServiceException a = (AmazonServiceException) e; if (a.getErrorCode().equals("RequestLimitExceeded")) { logWarn("RequestLimitExceeded", context); } else if (a instanceof AWSSecurityTokenServiceException) { logWarn(a.toString(), context); } else { logError(a, context); } } else { logError(e, context); } }  @Override void onException(Exception e, Map<String, String> context);  }
@Test public void onException() throws Exception { jobExceptionHandler.onException(new IllegalArgumentException("Oops"), ImmutableMap.of("foo", "bar")); }
@Test public void onRequestLimitExceededException() throws Exception { final AmazonServiceException exception = new AmazonServiceException("Oops"); exception.setErrorCode("RequestLimitExceeded"); jobExceptionHandler.onException(exception, ImmutableMap.of("aws_account", "111222333444")); }
@Test public void onStsException() throws Exception { final AmazonServiceException exception = new AWSSecurityTokenServiceException("bla"); exception.setErrorCode("SomethingElse"); jobExceptionHandler.onException(exception, ImmutableMap.of("aws_account", "111222333444")); }
@Test public void onAmazonException() throws Exception { final AmazonServiceException exception = new AmazonServiceException("bla"); exception.setErrorCode("SomethingElse"); jobExceptionHandler.onException(exception, ImmutableMap.of("aws_account", "111222333444")); }