From 45f9a10bfbbdcf0ba22fc2431f1e061353106075 Mon Sep 17 00:00:00 2001 From: Jimmy Kiselak Date: Sat, 12 Mar 2016 14:08:15 -0500 Subject: [PATCH] hide exceptions that show up in the dht and due to bad metadata in the blockchain --- lbrynet/core/LBRYcrdWallet.py | 4 ++-- lbrynet/dht/encoding.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py index 46279a2e4..09bc1e7bc 100644 --- a/lbrynet/core/LBRYcrdWallet.py +++ b/lbrynet/core/LBRYcrdWallet.py @@ -294,7 +294,7 @@ class LBRYWallet(object): value = result['value'] try: value_dict = json.loads(value) - except ValueError: + except (ValueError, TypeError): return Failure(InvalidStreamInfoError(name)) known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail', 'content_license'] @@ -395,7 +395,7 @@ class LBRYWallet(object): if 'name' in claim and str(claim['name']) == name and 'value' in claim: try: value_dict = json.loads(claim['value']) - except ValueError: + except (ValueError, TypeError): return None if 'stream_hash' in value_dict and str(value_dict['stream_hash']) == sd_hash: if 'is controlling' in claim and claim['is controlling']: diff --git a/lbrynet/dht/encoding.py b/lbrynet/dht/encoding.py index a57747628..e0b42ee4f 100644 --- a/lbrynet/dht/encoding.py +++ b/lbrynet/dht/encoding.py @@ -99,7 +99,10 @@ class Bencode(Encoding): """ if len(data) == 0: raise DecodeError, 'Cannot decode empty string' - return self._decodeRecursive(data)[0] + try: + return self._decodeRecursive(data)[0] + except ValueError as e: + raise DecodeError, e.message @staticmethod def _decodeRecursive(data, startIndex=0):