Use AssertionErrorWithCause from GWT, too.
It saves us the trouble of manually calling initCause() and leaving a comment.
More importantly, if we start omitting "java.lang.AssertionError: " failure messages, as I hope to do, this CL ensures that the change will happen in GWT, too.
[]
RELNOTES=n/a
@@ -17,6 +17,7 @@ package com.google.common.truth;
import static com.google.common.truth.StringUtil.format;
+import com.google.common.truth.Truth.AssertionErrorWithCause;
import java.util.LinkedHashSet;
import java.util.Set;
import jsinterop.annotations.JsPackage;
@@ -56,10 +57,8 @@ final class Platform {
static AssertionError comparisonFailure(
String message, String expected, String actual, Throwable cause) {
- AssertionError failure =
- new AssertionError(format("%s expected:<[%s]> but was:<[%s]>", message, expected, actual));
- failure.initCause(cause); // Not affected by Android bug
- return failure;
+ throw new AssertionErrorWithCause(
+ format("%s expected:<[%s]> but was:<[%s]>", message, expected, actual), cause);
}
/** Determines if the given subject contains a match for the given regex. */
