graphql.kickstart.spring.error.Throwables Maven / Gradle / Ivy
package graphql.kickstart.spring.error;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
class Throwables {
private List> exceptions;
Throwables(Class extends Throwable>[] exceptions) {
this.exceptions = Arrays.asList(exceptions);
}
Optional> mostConcrete(Throwable throwable) {
return exceptions.stream()
.filter(t -> t.isAssignableFrom(throwable.getClass()))
.min(new ThrowableComparator());
}
}