Skip to content

Commit f426cde

Browse files
alb-i986lukeis
authored andcommitted
Fix CoveringUpSauceErrorsRule: the original exception was lost
When re-creating the driver fails, throw the original exception, and expose the exception occurred while re-creating the driver as a suppressed exception. Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent 99abe79 commit f426cde

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ public void evaluate() throws Throwable {
168168
}
169169

170170
private void dealWithSauceFailureIfNecessary(Throwable t) {
171-
if (!(t instanceof AssumptionViolatedException) && t.getMessage() != null
172-
&& (t.getMessage().contains("sauce") || t.getMessage().contains("Sauce"))) {
173-
removeDriver();
171+
String message = t.getMessage();
172+
if (!(t instanceof AssumptionViolatedException) && message != null
173+
&& (message.contains("sauce") || message.contains("Sauce"))) {
174174
try {
175+
removeDriver();
175176
createDriver();
176177
} catch (Exception e) {
177-
throw new RuntimeException("Exception creating driver, after Sauce-detected exception", e);
178+
t.addSuppressed(e);
179+
throw new RuntimeException("Sauce-related failure. Tried re-creating the driver, but that failed too.", t);
178180
}
179181
} else {
180182
throw Throwables.propagate(t);

0 commit comments

Comments
 (0)