ruff exceptions: various

This commit is contained in:
The MMGen Project 2026-10-26 13:36:48 +00:00
commit 1a3f11ba51
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 9 additions and 9 deletions

View file

@ -287,8 +287,8 @@ def get_words_from_file(cfg, infile, *, desc, quiet=False):
try:
words = data.decode().split()
except:
die(1, f'{capfirst(desc)} data must be UTF-8 encoded.')
except UnicodeError as e:
die(1, f'{capfirst(desc)} data must be UTF-8 encoded ({e})')
cfg._util.dmsg('Sanitized input: [{}]'.format(' '.join(words)))

View file

@ -362,7 +362,7 @@ def _get_obj(clsname, cfg, *args, coin=None, network='mainnet', infile=None, dat
try:
msg_cls = importlib.import_module(
f'mmgen.proto.{proto.base_proto_coin.lower()}.msg').coin_msg
except:
except ImportError:
die(1, f'Message signing operations not supported for {proto.base_proto} protocol')
me = MMGenObject.__new__(getattr(msg_cls, clsname, getattr(coin_msg, clsname)))

View file

@ -34,8 +34,8 @@ match gc.platform:
case 'win32':
try:
import msvcrt # pylint: disable=import-error
except:
die(2, 'Unable to set terminal mode')
except ImportError as e:
die(2, f'Unable to set terminal mode ({e})')
if not sys.stdin.isatty():
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
case x:

View file

@ -25,7 +25,7 @@ from .new import New
def get_send_proto(cfg):
try:
arg = cfg._args.pop(0)
except:
except IndexError:
cfg._usage()
return init_swap_proto(cfg, get_swap_asset(cfg, arg, direction='send'))
@ -93,7 +93,7 @@ class NewSwap(BaseSwapMethods, New):
def get_arg():
try:
return args_in.pop(0)
except:
except IndexError:
self.cfg._usage()
async def parse():

View file

@ -148,6 +148,6 @@ class CmdTestBase:
imsg(purple(f'Killing {desc} [PID {pid}]'))
try:
os.kill(pid, SIGTERM)
except:
except ProcessLookupError:
imsg(yellow(f'{pid}: no such process'))
return 'ok'

View file

@ -175,7 +175,7 @@ def get_comment(do_shuffle=False):
global label_iter
try:
return next(label_iter)
except:
except (NameError, StopIteration):
if do_shuffle:
shuffle(labels)
label_iter = iter(labels)