1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.errors;
12
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.List;
17
18 import org.eclipse.jgit.internal.JGitText;
19
20
21
22
23 public class CompoundException extends Exception {
24 private static final long serialVersionUID = 1L;
25
26 private static String format(Collection<Throwable> causes) {
27 final StringBuilder msg = new StringBuilder();
28 msg.append(JGitText.get().failureDueToOneOfTheFollowing);
29 for (Throwable c : causes) {
30 msg.append(" ");
31 msg.append(c.getMessage());
32 msg.append("\n");
33 }
34 return msg.toString();
35 }
36
37 private final List<Throwable> causeList;
38
39
40
41
42
43
44
45 public CompoundException(Collection<Throwable> why) {
46 super(format(why));
47 causeList = Collections.unmodifiableList(new ArrayList<>(why));
48 }
49
50
51
52
53
54
55 public List<Throwable> getAllCauses() {
56 return causeList;
57 }
58 }