io.polyglotted.eswrapper.services.IndexerException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of es-wrapper Show documentation
Show all versions of es-wrapper Show documentation
Standard set of utilities for elastic search abstraction
package io.polyglotted.eswrapper.services;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Map.Entry;
@SuppressWarnings("serial")
public class IndexerException extends RuntimeException {
public final ImmutableMap errorsMap;
protected IndexerException(ImmutableMap errorsMap) {
super((String) errorsMap.get("ERROR_MESSAGE"));
this.errorsMap = errorsMap;
}
public static void checkErrors(Map errorsMap) {
if (!errorsMap.isEmpty()) {
throw new IndexerException(ImmutableMap.of("ERROR_MESSAGE",
buildFailureMessage("indexing failed:", errorsMap), "ERRORS", errorsMap));
}
}
static String buildFailureMessage(String message, Map errorsMap) {
StringBuilder sb = new StringBuilder();
sb.append(message);
for (Entry entry : errorsMap.entrySet())
sb.append("\n[").append(entry.getKey()).append("]: ").append(entry.getValue());
return sb.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy