use of com.facebook.stetho.inspector.jsonrpc.protocol.JsonRpcError in project stetho by facebook.
the class Database method getDatabaseTableNames.
@ChromeDevtoolsMethod
public JsonRpcResult getDatabaseTableNames(JsonRpcPeer peer, JSONObject params) throws JsonRpcException {
GetDatabaseTableNamesRequest request = mObjectMapper.convertValue(params, GetDatabaseTableNamesRequest.class);
String databaseId = request.databaseId;
DatabaseDriver databaseDriver = getDatabasePeer(databaseId);
try {
GetDatabaseTableNamesResponse response = new GetDatabaseTableNamesResponse();
response.tableNames = databaseDriver.getTableNames(request.databaseId);
return response;
} catch (SQLiteException e) {
throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INVALID_REQUEST, e.toString(), null));
}
}
use of com.facebook.stetho.inspector.jsonrpc.protocol.JsonRpcError in project stetho by facebook.
the class Runtime method callFunctionOn.
@ChromeDevtoolsMethod
public CallFunctionOnResponse callFunctionOn(JsonRpcPeer peer, JSONObject params) throws JsonRpcException {
CallFunctionOnRequest args = mObjectMapper.convertValue(params, CallFunctionOnRequest.class);
Session session = getSession(peer);
Object object = session.getObjectOrThrow(args.objectId);
// what this function does by name.
if (!args.functionDeclaration.startsWith("function protoList(")) {
throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INTERNAL_ERROR, "Expected protoList, got: " + args.functionDeclaration, null));
}
// Since this is really a function call we have to create this fake object to hold the
// "result" of the function.
ObjectProtoContainer objectContainer = new ObjectProtoContainer(object);
RemoteObject result = new RemoteObject();
result.type = ObjectType.OBJECT;
result.subtype = ObjectSubType.NODE;
result.className = object.getClass().getName();
result.description = getPropertyClassName(object);
result.objectId = String.valueOf(session.getObjects().putObject(objectContainer));
CallFunctionOnResponse response = new CallFunctionOnResponse();
response.result = result;
response.wasThrown = false;
return response;
}
use of com.facebook.stetho.inspector.jsonrpc.protocol.JsonRpcError in project stetho by facebook.
the class DOM method resolveNode.
@ChromeDevtoolsMethod
public ResolveNodeResponse resolveNode(JsonRpcPeer peer, JSONObject params) throws JsonRpcException {
final ResolveNodeRequest request = mObjectMapper.convertValue(params, ResolveNodeRequest.class);
final Object element = mDocument.postAndWait(new UncheckedCallable<Object>() {
@Override
public Object call() {
return mDocument.getElementForNodeId(request.nodeId);
}
});
if (element == null) {
throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INVALID_PARAMS, "No known nodeId=" + request.nodeId, null));
}
int mappedObjectId = Runtime.mapObject(peer, element);
Runtime.RemoteObject remoteObject = new Runtime.RemoteObject();
remoteObject.type = Runtime.ObjectType.OBJECT;
remoteObject.subtype = Runtime.ObjectSubType.NODE;
remoteObject.className = element.getClass().getName();
// not a primitive
remoteObject.value = null;
// not sure what this does...
remoteObject.description = null;
remoteObject.objectId = String.valueOf(mappedObjectId);
ResolveNodeResponse response = new ResolveNodeResponse();
response.object = remoteObject;
return response;
}
use of com.facebook.stetho.inspector.jsonrpc.protocol.JsonRpcError in project stetho by facebook.
the class Network method readResponseBody.
private GetResponseBodyResponse readResponseBody(String requestId) throws IOException, JsonRpcException {
GetResponseBodyResponse response = new GetResponseBodyResponse();
ResponseBodyData bodyData;
try {
bodyData = mResponseBodyFileManager.readFile(requestId);
} catch (OutOfMemoryError e) {
throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INTERNAL_ERROR, e.toString(), null));
}
response.body = bodyData.data;
response.base64Encoded = bodyData.base64Encoded;
return response;
}
Aggregations