From 7cccb451d2dca1d08e43a4387c137a424b9a8f57 Mon Sep 17 00:00:00 2001 From: wltsmrz Date: Thu, 4 Sep 2014 20:13:04 -0700 Subject: [PATCH] Show field name in serialization failure --- src/js/ripple/serializedtypes.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/ripple/serializedtypes.js b/src/js/ripple/serializedtypes.js index e7e7d80b..5eab078f 100644 --- a/src/js/ripple/serializedtypes.js +++ b/src/js/ripple/serializedtypes.js @@ -117,7 +117,7 @@ SerializedType.prototype.parse_varint = function (so) { */ function append_byte_array(so, val, bytes) { if (!isNumber(val)) { - throw new Error('Value is not a number'); + throw new Error('Value is not a number', bytes); } if (val < 0 || val >= Math.pow(256, bytes)) { @@ -625,7 +625,13 @@ function serialize(so, field_name, value) { // Get the serializer class (ST...) for a field based on the type bits. var serialized_object_type = exports[binformat.types[type_bits]]; //do something with val[keys] and val[keys[i]]; - serialized_object_type.serialize(so, value); + + try { + serialized_object_type.serialize(so, value); + } catch (e) { + e.message += ' (' + field_name + ')'; + throw e; + } } //Take the serialized object, figure out what type/field it is, and return the parsing of that.