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