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

Unified Diff: mojo/public/js/codec.js

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 | « gin/function_template.h ('k') | mojo/public/js/codec_unittests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/codec.js
diff --git a/mojo/public/js/codec.js b/mojo/public/js/codec.js
index ea4273a32ffd67e1398a1970a67ed1848f402e3f..5440abed92d3651e684a492f97673bee286d9d68 100644
--- a/mojo/public/js/codec.js
+++ b/mojo/public/js/codec.js
@@ -8,6 +8,7 @@ define("mojo/public/js/codec", [
], function(unicode, buffer) {
var kErrorUnsigned = "Passing negative value to unsigned";
+ var kErrorArray = "Passing non-array-like to array";
// Memory -------------------------------------------------------------------
@@ -352,6 +353,9 @@ define("mojo/public/js/codec", [
this.encodePointer(val);
return;
}
+ if (val.length === undefined) {
+ throw new Error(kErrorArray);
hansmuller 2014/12/15 16:56:17 I suppose another indication that val isn't an arr
+ }
var numberOfElements = val.length;
var encodedSize = kArrayHeaderSize + ((cls === PackedBool) ?
Math.ceil(numberOfElements / 8) : cls.encodedSize * numberOfElements);
« no previous file with comments | « gin/function_template.h ('k') | mojo/public/js/codec_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698