Don't catch errors that can't happen

This commit is contained in:
Matthias 2021-03-02 06:59:58 +01:00
parent 007ac7abb5
commit 4bb6a27745

View File

@ -721,20 +721,17 @@ class Telegram(RPCHandler):
Handler for /locks. Handler for /locks.
Returns the currently active locks Returns the currently active locks
""" """
try: locks = self._rpc._rpc_locks()
locks = self._rpc._rpc_locks() message = tabulate([[
message = tabulate([[ lock['id'],
lock['id'], lock['pair'],
lock['pair'], lock['lock_end_time'],
lock['lock_end_time'], lock['reason']] for lock in locks['locks']],
lock['reason']] for lock in locks['locks']], headers=['ID', 'Pair', 'Until', 'Reason'],
headers=['ID', 'Pair', 'Until', 'Reason'], tablefmt='simple')
tablefmt='simple') message = f"<pre>{escape(message)}</pre>"
message = f"<pre>{escape(message)}</pre>" logger.debug(message)
logger.debug(message) self._send_msg(message, parse_mode=ParseMode.HTML)
self._send_msg(message, parse_mode=ParseMode.HTML)
except RPCException as e:
self._send_msg(str(e))
@authorized_only @authorized_only
def _delete_locks(self, update: Update, context: CallbackContext) -> None: def _delete_locks(self, update: Update, context: CallbackContext) -> None:
@ -742,20 +739,17 @@ class Telegram(RPCHandler):
Handler for /delete_locks. Handler for /delete_locks.
Returns the currently active locks Returns the currently active locks
""" """
try: arg = context.args[0] if context.args and len(context.args) > 0 else None
arg = context.args[0] if context.args and len(context.args) > 0 else None lockid = None
lockid = None pair = None
pair = None if arg:
if arg: try:
try: lockid = int(arg)
lockid = int(arg) except ValueError:
except ValueError: pair = arg
pair = arg
self._rpc._rpc_delete_lock(lockid=lockid, pair=pair) self._rpc._rpc_delete_lock(lockid=lockid, pair=pair)
self._locks(update, context) self._locks(update, context)
except RPCException as e:
self._send_msg(str(e))
@authorized_only @authorized_only
def _whitelist(self, update: Update, context: CallbackContext) -> None: def _whitelist(self, update: Update, context: CallbackContext) -> None: