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

Unified Diff: headless/lib/browser/headless_devtools_client_impl.cc

Issue 2539833002: Deliver errors from devtools API calls to callbacks (Closed)
Patch Set: Addressed review comments Created 4 years 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
Index: headless/lib/browser/headless_devtools_client_impl.cc
diff --git a/headless/lib/browser/headless_devtools_client_impl.cc b/headless/lib/browser/headless_devtools_client_impl.cc
index 22f52946e4969707b50dac9e77528cb9fe6b6065..b6e2905a405e8823c552ad6408b1668aa4763412 100644
--- a/headless/lib/browser/headless_devtools_client_impl.cc
+++ b/headless/lib/browser/headless_devtools_client_impl.cc
@@ -126,11 +126,16 @@ bool HeadlessDevToolsClientImpl::DispatchMessageReply(
pending_messages_.erase(it);
if (!callback.callback_with_result.is_null()) {
const base::DictionaryValue* result_dict;
- if (!message_dict.GetDictionary("result", &result_dict)) {
- NOTREACHED() << "Badly formed reply result";
+ if (message_dict.GetDictionary("result", &result_dict)) {
+ callback.callback_with_result.Run(*result_dict);
+ } else if (message_dict.GetDictionary("error", &result_dict)) {
+ std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue();
+ DLOG(ERROR) << "Error in method call result: " << *result_dict;
+ callback.callback_with_result.Run(*null_value);
+ } else {
+ NOTREACHED() << "Reply has neither result nor error";
return false;
}
- callback.callback_with_result.Run(*result_dict);
} else if (!callback.callback.is_null()) {
callback.callback.Run();
}
« no previous file with comments | « headless/lib/browser/devtools_api/domain_cc.template ('k') | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698