[Pkg-javascript-commits] [node-asn1.js] 56/202: lib: better error reporting

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:18:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-asn1.js.

commit ff24a851d8e7684701b4ca8dc9e718e1b435235a
Author: Fedor Indutny <fedor at indutny.com>
Date:   Tue Nov 4 13:22:17 2014 -0500

    lib: better error reporting
---
 lib/asn1/base/buffer.js | 4 ++--
 lib/asn1/base/node.js   | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/asn1/base/buffer.js b/lib/asn1/base/buffer.js
index 81a8405..ff94be6 100644
--- a/lib/asn1/base/buffer.js
+++ b/lib/asn1/base/buffer.js
@@ -67,7 +67,7 @@ function EncoderBuffer(value, reporter) {
     this.length = 0;
     this.value = value.map(function(item) {
       if (!(item instanceof EncoderBuffer))
-        item = new EncoderBuffer(item);
+        item = new EncoderBuffer(item, reporter);
       this.length += item.length;
       return item;
     }, this);
@@ -83,7 +83,7 @@ function EncoderBuffer(value, reporter) {
     this.value = value;
     this.length = value.length;
   } else {
-    return reporter.error('Unsupporter type: ' + typeof value);
+    return reporter.error('Unsupported type: ' + typeof value);
   }
 }
 exports.EncoderBuffer = EncoderBuffer;
diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index b653698..7eea127 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -524,6 +524,12 @@ Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
   var state = this._baseState;
 
   var node = state.choice[data.type];
+  if (!node) {
+    assert(
+        false,
+        data.type + ' not found in ' +
+            JSON.stringify(Object.keys(state.choice)));
+  }
   return node._encode(data.value, reporter);
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git



More information about the Pkg-javascript-commits mailing list