From e12e9c4155a2ddac83ad92bdf2063821cbd7d1ea Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 29 Nov 2021 17:30:39 +0200 Subject: [PATCH] Add exception type in HandleSendMessage and HandleSendBroadcast and API error 14 in HandleSendBroadcast. --- src/api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api.py b/src/api.py index 3300fc72..0d802d61 100644 --- a/src/api.py +++ b/src/api.py @@ -1118,9 +1118,8 @@ class BMRPCDispatcher(object): fromAddress = addBMIfNotPresent(fromAddress) self._verifyAddress(fromAddress) try: - fromAddressEnabled = self.config.getboolean( - fromAddress, 'enabled') - except BaseException: + fromAddressEnabled = self.config.getboolean(fromAddress, 'enabled') + except ConfigParser.NoSectionError: raise APIError( 13, 'Could not find your fromAddress in the keys.dat file.') if not fromAddressEnabled: @@ -1164,10 +1163,13 @@ class BMRPCDispatcher(object): fromAddress = addBMIfNotPresent(fromAddress) self._verifyAddress(fromAddress) try: - self.config.getboolean(fromAddress, 'enabled') - except BaseException: + fromAddressEnabled = self.config.getboolean(fromAddress, 'enabled') + except ConfigParser.NoSectionError: raise APIError( 13, 'Could not find your fromAddress in the keys.dat file.') + if not fromAddressEnabled: + raise APIError(14, 'Your fromAddress is disabled. Cannot send.') + toAddress = str_broadcast_subscribers ackdata = helper_sent.insert(