Skip to content

Commit 7a48c94

Browse files
committed
[java] ignore null text of UnhandledAlertException
1 parent 192dea5 commit 7a48c94

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,20 @@ public Map<String, Object> encode(Throwable throwable) {
114114
}
115115

116116
if (throwable instanceof UnhandledAlertException) {
117-
Map<String, String> data =
118-
Map.of("text", ((UnhandledAlertException) throwable).getAlertText());
119-
return Map.of(
120-
"value",
121-
Map.of(
122-
"error",
123-
err.w3cErrorString,
124-
"message",
125-
message,
126-
"stacktrace",
127-
stacktrace.toString(),
128-
"data",
129-
data));
117+
String text = ((UnhandledAlertException) throwable).getAlertText();
118+
if (text != null) {
119+
return Map.of(
120+
"value",
121+
Map.of(
122+
"error",
123+
err.w3cErrorString,
124+
"message",
125+
message,
126+
"stacktrace",
127+
stacktrace.toString(),
128+
"data",
129+
Map.of("text", text)));
130+
}
130131
}
131132

132133
return Map.of(

0 commit comments

Comments
 (0)