Skip to content

Commit d66494e

Browse files
authored
[java] Rescuing the remote cause for session creation errors (#16418)
* [java] Rescuing the remote cause for session creation errors Fixes #16388 * Code improvement, thanks to @valfirst
1 parent 8ddb020 commit d66494e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,14 @@ protected Response execute(CommandPayload payload) {
572572
if (e instanceof SessionNotCreatedException) {
573573
toThrow = (WebDriverException) e;
574574
} else {
575+
// When this exception comes from a remote end, the real cause is usually hidden in the
576+
// cause. Let's try to rescue it and display it at the top level.
577+
String cause = e.getCause() != null ? " " + e.getCause().getMessage() : "";
575578
toThrow =
576579
new SessionNotCreatedException(
577580
"Possible causes are invalid address of the remote server or browser start-up"
578-
+ " failure.",
581+
+ " failure."
582+
+ cause,
579583
e);
580584
}
581585
} else if (e instanceof WebDriverException) {

0 commit comments

Comments
 (0)