Lines Matching defs:exceptions
27 * "throw multiple exceptions", or something close to it. The prototypical code
43 * List<Exception> exceptions = Lists.newArrayList();
48 * exceptions.add(e);
51 * if (exceptions.size() > 0) {
52 * throw ClusterException.create(exceptions);
64 public final Collection<? extends Throwable> exceptions;
66 private ClusterException(Collection<? extends Throwable> exceptions) {
68 exceptions.size() + " exceptions were thrown. The first exception is listed as a cause.",
69 exceptions.iterator().next());
71 temp.addAll(exceptions);
72 this.exceptions = Collections.unmodifiableCollection(temp);
78 public static RuntimeException create(Throwable... exceptions) {
80 for (Throwable exception : exceptions) {
87 * Given a collection of exceptions, returns a {@link RuntimeException}, with
91 * <li>If {@code exceptions} has a single exception and that exception is a
93 * <li>If {@code exceptions} has a single exceptions and that exceptions is
97 * the first exception in the {@code exceptions} collection.
102 * preserves the order in which the exceptions got added.
104 * @throws NullPointerException if {@code exceptions} is null
105 * @throws IllegalArgumentException if {@code exceptions} is empty
107 public static RuntimeException create(Collection<? extends Throwable> exceptions) {
108 if (exceptions.size() == 0) {
110 "Can't create an ExceptionCollection with no exceptions");
112 if (exceptions.size() == 1) {
113 Throwable temp = exceptions.iterator().next();
120 return new ClusterException(exceptions);