Skip to content

Commit 17bc2e6

Browse files
authored
[grid] Use a valid json for error message
1 parent 4cde9ff commit 17bc2e6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

java/src/org/openqa/selenium/grid/web/RoutableHttpClientFactory.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.openqa.selenium.grid.web;
1919

20+
import org.openqa.selenium.UnsupportedCommandException;
2021
import org.openqa.selenium.internal.Require;
2122
import org.openqa.selenium.remote.http.ClientConfig;
2223
import org.openqa.selenium.remote.http.HttpClient;
@@ -28,7 +29,9 @@
2829
import java.net.URI;
2930
import java.net.URL;
3031

31-
import static org.openqa.selenium.remote.http.Contents.utf8String;
32+
import static org.openqa.selenium.remote.http.Contents.asJson;
33+
34+
import com.google.common.collect.ImmutableMap;
3235

3336
public class RoutableHttpClientFactory implements HttpClient.Factory {
3437

@@ -59,7 +62,10 @@ public HttpResponse execute(HttpRequest request) throws UncheckedIOException {
5962

6063
if (!handler.test(request)) {
6164
response.setStatus(404);
62-
response.setContent(utf8String("Unable to route " + request));
65+
response.setContent(asJson(ImmutableMap.of(
66+
"value", request.getUri(),
67+
"message", "Unable to route " + request,
68+
"error", UnsupportedCommandException.class.getName())));
6369
return response;
6470
}
6571

0 commit comments

Comments
 (0)