Skip to content

Commit

Permalink
Fix CoveringUpSauceErrorsRule: the original exception was lost
Browse files Browse the repository at this point in the history
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 <luke.semerau@gmail.com>
  • Loading branch information
alb-i986 authored and lukeis committed Apr 13, 2016
1 parent 99abe79 commit f426cde
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ public void evaluate() throws Throwable {
}

private void dealWithSauceFailureIfNecessary(Throwable t) {
if (!(t instanceof AssumptionViolatedException) && t.getMessage() != null
&& (t.getMessage().contains("sauce") || t.getMessage().contains("Sauce"))) {
removeDriver();
String message = t.getMessage();
if (!(t instanceof AssumptionViolatedException) && message != null
&& (message.contains("sauce") || message.contains("Sauce"))) {
try {
removeDriver();
createDriver();
} catch (Exception e) {
throw new RuntimeException("Exception creating driver, after Sauce-detected exception", e);
t.addSuppressed(e);
throw new RuntimeException("Sauce-related failure. Tried re-creating the driver, but that failed too.", t);
}
} else {
throw Throwables.propagate(t);
Expand Down

0 comments on commit f426cde

Please sign in to comment.