coolbong/node-tlv

Missing country currency code

cfurter opened this issue · 2 comments

When the currency code is not in the CurrencyCode.json file, an exception is thrown.

Here is my fix, I could not create a pull request.

diff --git a/lib/Decoder.js b/lib/Decoder.js
index 3eb9e4e..e951817 100644
--- a/lib/Decoder.js
+++ b/lib/Decoder.js
@@ -291,10 +291,12 @@ function getCurrencyCode(tlv) {
         });

         var obj = array[0];
-        desc.push('Code: [' + obj['code'] + '] : ' + obj['currency']);
-
+        if (obj)
+            desc.push('Code: [' + obj['code'] + '] : ' + obj['currency']);
+        else
+            desc.push('unknown country code ' + value + '. plz update ISO3166.');
     } else {
-        desc.push('unknown country code. plz update ISO3166.');
+        desc.push('no country codes? plz load.');
     }
     return desc;
 }
@@ -303,4 +305,4 @@ module.exports = {
     setDecoder: setDecoder
 };

I fixed. plz check the codes.
thank you.