checkAsyncCallResult(JSON::Value::create(makeString("Object has too long reference chain (must not be longer than "_s, JSON::Value::maxDepth, ')')), callback);
errorString = "Internal error: result value is empty"_s;
return;
}
if (result->type() == JSON::Value::Type::String) {
errorString = result->asString();
return;
}
auto resultTuple = result->asObject();
if (!resultTuple) {
errorString = "Internal error: result is not an Object"_s;
return;
}
auto typelessResultObject = resultTuple->getObject("result"_s);
if (!typelessResultObject) {
// FIXME: Why do we bother checking for null here, but not checking that the type is Protocol::Runtime::RemoteObject? Surely the two possible errors go hand in hand.
errorString = "Internal error: result is not a pair of value and wasThrown flag"_s;