/** * Rethrows the first exception in the list and adds all remaining to the suppressed list. * If the given list is empty no exception is thrown * */ public static <T extends Throwable> void rethrowAndSuppress(List<T> exceptions) throws T { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw main; } }
/** * Throws a runtime exception with all given exceptions added as suppressed. * If the given list is empty no exception is thrown */ public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> exceptions) { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw new ElasticsearchException(main); } }
public static List<Processor> readProcessorConfigs(List<Map<String, Object>> processorConfigs, ScriptService scriptService, Map<String, Processor.Factory> processorFactories) throws Exception { Exception exception = null; List<Processor> processors = new ArrayList<>(); if (processorConfigs != null) { for (Map<String, Object> processorConfigWithKey : processorConfigs) { for (Map.Entry<String, Object> entry : processorConfigWithKey.entrySet()) { try { processors.add(readProcessor(processorFactories, scriptService, entry.getKey(), entry.getValue())); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } } } if (exception != null) { throw exception; } return processors; }
@Override public void validateSearchContext(SearchContext context, TransportRequest request) { Exception exception = null; for (SearchOperationListener listener : listeners) { try { listener.validateSearchContext(context, request); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } ExceptionsHelper.reThrowIfNotNull(exception); } }
/** * Rethrows the first exception in the list and adds all remaining to the suppressed list. * If the given list is empty no exception is thrown * */ public static <T extends Throwable> void rethrowAndSuppress(List<T> exceptions) throws T { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw main; } }
/** * Rethrows the first exception in the list and adds all remaining to the suppressed list. * If the given list is empty no exception is thrown * */ public static <T extends Throwable> void rethrowAndSuppress(List<T> exceptions) throws T { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw main; } }
/** * Rethrows the first exception in the list and adds all remaining to the suppressed list. * If the given list is empty no exception is thrown * */ public static <T extends Throwable> void rethrowAndSuppress(List<T> exceptions) throws T { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw main; } }
/** * Throws a runtime exception with all given exceptions added as suppressed. * If the given list is empty no exception is thrown */ public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> exceptions) { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw new ElasticsearchException(main); } }
/** * Throws a runtime exception with all given exceptions added as suppressed. * If the given list is empty no exception is thrown */ public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> exceptions) { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw new ElasticsearchException(main); } }
/** * Throws a runtime exception with all given exceptions added as suppressed. * If the given list is empty no exception is thrown */ public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> exceptions) { T main = null; for (T ex : exceptions) { main = useOrSuppress(main, ex); } if (main != null) { throw new ElasticsearchException(main.getMessage(), main); } }
public static List<Processor> readProcessorConfigs(List<Map<String, Map<String, Object>>> processorConfigs, Map<String, Processor.Factory> processorFactories) throws Exception { Exception exception = null; List<Processor> processors = new ArrayList<>(); if (processorConfigs != null) { for (Map<String, Map<String, Object>> processorConfigWithKey : processorConfigs) { for (Map.Entry<String, Map<String, Object>> entry : processorConfigWithKey.entrySet()) { try { processors.add(readProcessor(processorFactories, entry.getKey(), entry.getValue())); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } } } if (exception != null) { throw exception; } return processors; }
public static List<Processor> readProcessorConfigs(List<Map<String, Map<String, Object>>> processorConfigs, Map<String, Processor.Factory> processorFactories) throws Exception { Exception exception = null; List<Processor> processors = new ArrayList<>(); if (processorConfigs != null) { for (Map<String, Map<String, Object>> processorConfigWithKey : processorConfigs) { for (Map.Entry<String, Map<String, Object>> entry : processorConfigWithKey.entrySet()) { try { processors.add(readProcessor(processorFactories, entry.getKey(), entry.getValue())); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } } } if (exception != null) { throw exception; } return processors; }
public static List<Processor> readProcessorConfigs(List<Map<String, Object>> processorConfigs, ScriptService scriptService, Map<String, Processor.Factory> processorFactories) throws Exception { Exception exception = null; List<Processor> processors = new ArrayList<>(); if (processorConfigs != null) { for (Map<String, Object> processorConfigWithKey : processorConfigs) { for (Map.Entry<String, Object> entry : processorConfigWithKey.entrySet()) { try { processors.add(readProcessor(processorFactories, scriptService, entry.getKey(), entry.getValue())); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } } } if (exception != null) { throw exception; } return processors; }
@Override public void validateSearchContext(SearchContext context, TransportRequest request) { Exception exception = null; for (SearchOperationListener listener : listeners) { try { listener.validateSearchContext(context, request); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } ExceptionsHelper.reThrowIfNotNull(exception); } }
@Override public void validateSearchContext(SearchContext context, TransportRequest request) { Exception exception = null; for (SearchOperationListener listener : listeners) { try { listener.validateSearchContext(context, request); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } ExceptionsHelper.reThrowIfNotNull(exception); } }
@Override public void validateSearchContext(SearchContext context, TransportRequest request) { Exception exception = null; for (SearchOperationListener listener : listeners) { try { listener.validateSearchContext(context, request); } catch (Exception e) { exception = ExceptionsHelper.useOrSuppress(exception, e); } } ExceptionsHelper.reThrowIfNotNull(exception); } }
@Override public IngestDocument execute(IngestDocument ingestDocument) { Object obj = ingestDocument.getFieldValue(field, Object.class); String value = null; if (obj != null) { // Not use Objects.toString(...) here, because null gets changed to "null" which may confuse some date parsers value = obj.toString(); } DateTime dateTime = null; Exception lastException = null; for (Function<Map<String, Object>, Function<String, DateTime>> dateParser : dateParsers) { try { dateTime = dateParser.apply(ingestDocument.getSourceAndMetadata()).apply(value); } catch (Exception e) { //try the next parser and keep track of the exceptions lastException = ExceptionsHelper.useOrSuppress(lastException, e); } } if (dateTime == null) { throw new IllegalArgumentException("unable to parse date [" + value + "]", lastException); } ingestDocument.setFieldValue(targetField, ISODateTimeFormat.dateTime().print(dateTime)); return ingestDocument; }
} catch (Exception e) { lastException = ExceptionsHelper.useOrSuppress(lastException, e);