From 107765dc461ecb72db5cb698dec4d658dd206dca Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Tue, 14 Aug 2018 22:22:19 +0000 Subject: [PATCH] Improve exceptions. --- asn1.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asn1.js b/asn1.js index d7783c8..2c56b0f 100644 --- a/asn1.js +++ b/asn1.js @@ -417,7 +417,7 @@ ASN1.decode = function (stream) { while (stream.pos < end) sub[sub.length] = ASN1.decode(stream); if (stream.pos != end) - throw "Content size is not correct for container starting at offset " + start; + throw 'Content size is not correct for container at offset ' + start; } else { // undefined length try { @@ -429,7 +429,7 @@ ASN1.decode = function (stream) { } len = start - stream.pos; // undefined lengths are represented as negative values } catch (e) { - throw "Exception while decoding undefined length content: " + e; + throw 'Exception while decoding undefined length content at offset ' + start + ': ' + e; } } }; @@ -449,6 +449,7 @@ ASN1.decode = function (stream) { } catch (e) { // but silently ignore when they don't sub = null; + //DEBUG console.log('Could not decode structure at ' + start + ':', e); } } if (sub === null) { -- 2.51.2