1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit.runners.model;
2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.Arrays;
4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.List;
5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/**
7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Represents one or more problems encountered while initializing a Runner
8aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin *
9aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin * @since 4.5
10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */
11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic class InitializationError extends Exception {
12aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    private static final long serialVersionUID = 1L;
13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
14aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    /*
15aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * We have to use the f prefix until the next major release to ensure
16aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * serialization compatibility.
17aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * See https://github.com/junit-team/junit/issues/976
18aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     */
19aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    private final List<Throwable> fErrors;
20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
21aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    /**
22aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * Construct a new {@code InitializationError} with one or more
23aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * errors {@code errors} as causes
24aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     */
25aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    public InitializationError(List<Throwable> errors) {
26aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin        this.fErrors = errors;
27aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    }
28aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin
29aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    public InitializationError(Throwable error) {
30aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin        this(Arrays.asList(error));
31aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    }
32aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin
33aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    /**
34aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * Construct a new {@code InitializationError} with one cause
35aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * with message {@code string}
36aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     */
37aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    public InitializationError(String string) {
38aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin        this(new Exception(string));
39aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    }
40aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin
41aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    /**
42aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     * Returns one or more Throwables that led to this initialization error.
43aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin     */
44aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    public List<Throwable> getCauses() {
45aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin        return fErrors;
46aeb93fc33cae3aadbb9b46083350ad2dc9aea645Paul Duffin    }
47b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}
48