JSONObject response = handler.getResponse(command.getInt("id"));
JSONObject error = response.optJSONObject("error");
if (error != null) {
throw new RemoteExceptionException(error, command);
} else if (response.optBoolean("wasThrown", false)) {
throw new WebDriverException("remote JS exception " + response.toString(2));
} else {
if (log.isLoggable(Level.FINE)) {
log.fine(
System.currentTimeMillis() + "\t\t" + (System.currentTimeMillis() - start) + "ms\t"
+ command.getString("method") + " " + command);
}
JSONObject res = response.getJSONObject("result");
if (res == null) {
System.err.println("GOT a null result from " + response.toString(2));
}
return res;
}
} catch (JSONException e) {
throw new WebDriverException(e);
} catch (NullPointerException e) {
throw new WebDriverException("the server didn't respond. Is the app still alive ?");
}
}