Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #247 from kcooney/initialization-error-message

Give InitializationError a useful message
  • Loading branch information...
commit ed2b51b0c78a079f806ea9157f77f83705f8e04b 2 parents 44d1324 + 00301d6
David Saff authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 src/main/java/org/junit/runners/model/InitializationError.java
View
18 src/main/java/org/junit/runners/model/InitializationError.java
@@ -1,6 +1,8 @@
package org.junit.runners.model;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -15,11 +17,11 @@
* errors {@code errors} as causes
*/
public InitializationError(List<Throwable> errors) {
- fErrors= errors;
+ fErrors= new ArrayList<Throwable>(errors);
}
public InitializationError(Throwable error) {
- this(Arrays.asList(error));
+ fErrors= Arrays.asList(error);
}
/**
@@ -34,6 +36,16 @@ public InitializationError(String string) {
* Returns one or more Throwables that led to this initialization error.
*/
public List<Throwable> getCauses() {
- return fErrors;
+ return Collections.unmodifiableList(fErrors);
+ }
+
+ @Override
+ public String getMessage() {
+ StringBuilder sb = new StringBuilder(
+ String.format("There were %d errors:", fErrors.size()));
+ for (Throwable e : fErrors) {
+ sb.append(String.format("\n %s(%s)", e.getClass().getName(), e.getMessage()));
+ }
+ return sb.toString();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.