1 package com.github.davidmoten.aws.lw.client; 2 3 import java.util.Optional; 4 5 import com.github.davidmoten.aws.lw.client.internal.ExceptionFactoryDefault; 6 7 @FunctionalInterface 8 public interface ExceptionFactory { 9 10 /** 11 * Returns a {@link RuntimeException} (or subclass) if the response error 12 * condition is met (usually {@code !response.isOk()}. If no exception to be 13 * thrown then returns {@code Optional.empty()}. 14 * 15 * @param response response to map into exception 16 * @return optional runtime exception 17 */ 18 Optional<? extends RuntimeException> create(Response response); 19 20 ExceptionFactory DEFAULT = new ExceptionFactoryDefault(); 21 }