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

Unified Diff: gin/arguments.cc

Issue 798163002: Add failure messages to gin and js mojom encoder (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | gin/function_template.h » ('j') | mojo/public/js/codec.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/arguments.cc
diff --git a/gin/arguments.cc b/gin/arguments.cc
index 6703fc2de53c4a874f6015a886d1903f825bfcac..30ff7849a2c9c5bbd0b2b5fd7d661f7b25f80810 100644
--- a/gin/arguments.cc
+++ b/gin/arguments.cc
@@ -32,12 +32,26 @@ v8::Handle<v8::Value> Arguments::PeekNext() const {
return (*info_)[next_];
}
+std::string V8TypeAsString(v8::Handle<v8::Value> value) {
+ if (value.IsEmpty())
+ return "<empty handle>";
+ if (value->IsUndefined())
+ return "undefined";
+ if (value->IsNull())
+ return "null";
+ std::string result;
+ if (!ConvertFromV8(NULL, value, &result))
+ return std::string();
+ return result;
+}
+
void Arguments::ThrowError() const {
if (insufficient_arguments_)
return ThrowTypeError("Insufficient number of arguments.");
- ThrowTypeError(base::StringPrintf(
- "Error processing argument %d.", next_ - 1));
+ return ThrowTypeError(base::StringPrintf(
+ "Error processing argument at index %d, conversion failure from %s",
+ next_ - 1, V8TypeAsString((*info_)[next_ - 1]).c_str()));
}
void Arguments::ThrowTypeError(const std::string& message) const {
« no previous file with comments | « no previous file | gin/function_template.h » ('j') | mojo/public/js/codec.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698