Skip to content

Commit

Permalink
[grid] Use a valid json for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani authored Sep 30, 2021
1 parent 4cde9ff commit 17bc2e6
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.grid.web;

import org.openqa.selenium.UnsupportedCommandException;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.remote.http.HttpClient;
Expand All @@ -28,7 +29,9 @@
import java.net.URI;
import java.net.URL;

import static org.openqa.selenium.remote.http.Contents.utf8String;
import static org.openqa.selenium.remote.http.Contents.asJson;

import com.google.common.collect.ImmutableMap;

public class RoutableHttpClientFactory implements HttpClient.Factory {

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

if (!handler.test(request)) {
response.setStatus(404);
response.setContent(utf8String("Unable to route " + request));
response.setContent(asJson(ImmutableMap.of(
"value", request.getUri(),
"message", "Unable to route " + request,
"error", UnsupportedCommandException.class.getName())));
return response;
}

Expand Down

0 comments on commit 17bc2e6

Please sign in to comment.