From 97c3f3335a19dc4c4b8bf2a2bb13ac3079ccc2da Mon Sep 17 00:00:00 2001
From: Holger Nahrstaedt <holgernahrstaedt@gmx.de>
Date: Fri, 9 Oct 2020 22:40:20 +0200
Subject: [PATCH] Fix detection when a vote does not exists on HF24

---
 CHANGELOG.rst |  3 ++-
 beem/vote.py  | 12 +++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index a0f77b3f..57629177 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -11,7 +11,8 @@ Changelog
 * Fix compatibility issues with HF 24
 * account get_follow_count, get_followers and get_following have been fixed
 * improved get_discussions calls, fallback to condenser when tags api not available
-* Fix detection when content does not exists
+* Fix detection when content does not exists on HF24
+* Fix detection when a vote does not exists on HF24
 
 0.24.9
 ------
diff --git a/beem/vote.py b/beem/vote.py
index 94cf30b7..7688c603 100644
--- a/beem/vote.py
+++ b/beem/vote.py
@@ -102,7 +102,11 @@ class Vote(BlockchainObject):
                 try:
                     votes = self.blockchain.rpc.get_active_votes({'author': author, 'permlink': permlink}, api="tags")['votes']
                 except:
-                    votes = self.blockchain.rpc.get_active_votes(author, permlink, api="database_api")
+                    from beemapi.exceptions import InvalidParameters
+                    try:
+                        votes = self.blockchain.rpc.get_active_votes(author, permlink, api="database_api")
+                    except InvalidParameters:
+                        raise VoteDoesNotExistsException(self.identifier)
             else:
                 votes = self.blockchain.rpc.get_active_votes(author, permlink, api="database_api")
         except UnkownKey:
@@ -378,8 +382,11 @@ class ActiveVotes(VotesObject):
             #    votes = authorperm["active_votes"]
             if self.blockchain.rpc.get_use_appbase():
                 self.blockchain.rpc.set_next_node_on_empty_reply(False)
+                from beemapi.exceptions import InvalidParameters
                 try:
                     votes = self.blockchain.rpc.get_active_votes(authorperm["author"], authorperm["permlink"], api="condenser")
+                except InvalidParameters:
+                    raise VoteDoesNotExistsException(construct_authorperm(authorperm["author"], authorperm["permlink"]))
                 except:
                     votes = self.blockchain.rpc.get_active_votes({'author': authorperm["author"],
                                                              'permlink': authorperm["permlink"]},
@@ -391,8 +398,11 @@ class ActiveVotes(VotesObject):
             [author, permlink] = resolve_authorperm(authorperm)
             if self.blockchain.rpc.get_use_appbase():
                 self.blockchain.rpc.set_next_node_on_empty_reply(False)
+                from beemapi.exceptions import InvalidParameters
                 try:
                     votes = self.blockchain.rpc.get_active_votes(author, permlink, api="condenser")
+                except InvalidParameters:
+                    raise VoteDoesNotExistsException(construct_authorperm(author, permlink))                    
                 except:
                     votes = self.blockchain.rpc.get_active_votes({'author': author,
                                                              'permlink': permlink},
-- 
GitLab