Handle null values in stack traces when marshalling exceptions
This should be a little more robust.
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.BeanToJsonConverter;
@@ -78,12 +75,12 @@ public void execute(HttpRequest req, HttpResponse resp) {
"stackTrace",
Stream.of(exception.getStackTrace())
.map(ste -> {
- JsonObject line = new JsonObject();
- line.add("fileName", new JsonPrimitive(ste.getFileName()));
- line.add("lineNumber", new JsonPrimitive(ste.getLineNumber()));
- line.add("className", new JsonPrimitive(ste.getClassName()));
- line.add("methodName", new JsonPrimitive(ste.getMethodName()));
- return ste;
+ HashMap<String, Object> line = new HashMap<>();
+ line.put("fileName", ste.getFileName());
+ line.put("lineNumber", ste.getLineNumber());
+ line.put("className", ste.getClassName());
+ line.put("methodName", ste.getMethodName());
+ return line;
})
.collect(ImmutableList.toImmutableList()));
