ElasticsearchExceptionHandler { public <T extends Throwable> void logOrThrow(T t) throws T { if (_logExceptionsOnly) { _log.error(t, t); } else if (_logExceptionsOnly) { _log.error(t, t); } else { throw t; } } ElasticsearchExceptionHandler(Log log, boolean logExceptionsOnly); void handleDeleteDocumentException(T t); void logOrThrow(T t);  }
@Test public void testLogExceptionsOnlyFalse() throws Throwable { expectedException.expect(SearchException.class); expectedException.expectMessage("some other random message"); ElasticsearchExceptionHandler elasticsearchExceptionHandler = new ElasticsearchExceptionHandler(_log, false); elasticsearchExceptionHandler.logOrThrow( new SearchException("some other random message")); }
@Test public void testLogExceptionsOnlyTrue() throws Throwable { expectedLogTestRule.expectMessage("some random message"); ElasticsearchExceptionHandler elasticsearchExceptionHandler = new ElasticsearchExceptionHandler(_log, true); elasticsearchExceptionHandler.logOrThrow( new SearchException("some random message")); }