
io.sphere.internal.errors.ErrorHandling Maven / Gradle / Ivy
package io.sphere.internal.errors;
import com.google.common.base.Function;
import io.sphere.client.SphereError;
import io.sphere.client.exceptions.SphereBackendException;
import io.sphere.client.exceptions.SphereException;
import static io.sphere.internal.util.Util.getSingleError;
public class ErrorHandling {
public static Function handleDuplicateField(final String fieldName, final SphereException exceptionToEmit) {
return new Function() {
public SphereException apply(SphereBackendException e) {
SphereError.DuplicateField err = getSingleError(e, SphereError.DuplicateField.class);
if (err != null && err.getField().equals(fieldName)) {
return exceptionToEmit;
}
return null;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy