001 package org.junit.runners.model;
002
003 import java.util.Arrays;
004 import java.util.List;
005
006 /**
007 * Represents one or more problems encountered while initializing a Runner
008 *
009 * @since 4.5
010 */
011 public class InitializationError extends Exception {
012 private static final long serialVersionUID = 1L;
013
014 /*
015 * We have to use the f prefix until the next major release to ensure
016 * serialization compatibility.
017 * See https://github.com/junit-team/junit4/issues/976
018 */
019 private final List<Throwable> fErrors;
020
021 /**
022 * Construct a new {@code InitializationError} with one or more
023 * errors {@code errors} as causes
024 */
025 public InitializationError(List<Throwable> errors) {
026 this.fErrors = errors;
027 }
028
029 public InitializationError(Throwable error) {
030 this(Arrays.asList(error));
031 }
032
033 /**
034 * Construct a new {@code InitializationError} with one cause
035 * with message {@code string}
036 */
037 public InitializationError(String string) {
038 this(new Exception(string));
039 }
040
041 /**
042 * Returns one or more Throwables that led to this initialization error.
043 */
044 public List<Throwable> getCauses() {
045 return fErrors;
046 }
047 }