Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: src/inspector/StringUtil.cpp

Issue 2345263003: [inspector] provide more usefull error message for non serializable value (Closed)
Patch Set: addressed comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/StringUtil.h ('k') | src/inspector/V8DebuggerAgentImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/StringUtil.cpp
diff --git a/src/inspector/StringUtil.cpp b/src/inspector/StringUtil.cpp
index 04b9e85c8f471566541cc27f5fb0d7b2f46e9fa1..b1aefc04d8825c17b58872bc7fb4f3da91d813f9 100644
--- a/src/inspector/StringUtil.cpp
+++ b/src/inspector/StringUtil.cpp
@@ -103,7 +103,8 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& string) {
} // namespace protocol
-std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
+std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString,
+ v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
int maxDepth) {
if (value.IsEmpty()) {
@@ -111,7 +112,10 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
return nullptr;
}
- if (!maxDepth) return nullptr;
+ if (!maxDepth) {
+ *errorString = "Object reference chain is too long";
+ return nullptr;
+ }
maxDepth--;
if (value->IsNull() || value->IsUndefined()) return protocol::Value::null();
@@ -134,9 +138,12 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> value;
- if (!array->Get(context, i).ToLocal(&value)) return nullptr;
+ if (!array->Get(context, i).ToLocal(&value)) {
+ *errorString = "Internal error";
+ return nullptr;
+ }
std::unique_ptr<protocol::Value> element =
- toProtocolValue(context, value, maxDepth);
+ toProtocolValue(errorString, context, value, maxDepth);
if (!element) return nullptr;
inspectorArray->pushValue(std::move(element));
}
@@ -147,12 +154,17 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
protocol::DictionaryValue::create();
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Local<v8::Array> propertyNames;
- if (!object->GetPropertyNames(context).ToLocal(&propertyNames))
+ if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) {
+ *errorString = "Internal error";
return nullptr;
+ }
uint32_t length = propertyNames->Length();
for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> name;
- if (!propertyNames->Get(context, i).ToLocal(&name)) return nullptr;
+ if (!propertyNames->Get(context, i).ToLocal(&name)) {
+ *errorString = "Internal error";
+ return nullptr;
+ }
// FIXME(yurys): v8::Object should support GetOwnPropertyNames
if (name->IsString()) {
v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty(
@@ -163,16 +175,19 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
v8::Local<v8::String> propertyName;
if (!name->ToString(context).ToLocal(&propertyName)) continue;
v8::Local<v8::Value> property;
- if (!object->Get(context, name).ToLocal(&property)) return nullptr;
+ if (!object->Get(context, name).ToLocal(&property)) {
+ *errorString = "Internal error";
+ return nullptr;
+ }
std::unique_ptr<protocol::Value> propertyValue =
- toProtocolValue(context, property, maxDepth);
+ toProtocolValue(errorString, context, property, maxDepth);
if (!propertyValue) return nullptr;
jsonObject->setValue(toProtocolString(propertyName),
std::move(propertyValue));
}
return std::move(jsonObject);
}
- UNREACHABLE();
+ *errorString = "Object couldn't be returned by value";
return nullptr;
}
« no previous file with comments | « src/inspector/StringUtil.h ('k') | src/inspector/V8DebuggerAgentImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698