зеркало из https://github.com/microsoft/CCF.git
Fix Pylint exception chaining warnings (#1519)
This commit is contained in:
Родитель
3909627c10
Коммит
6a3c82e653
|
@ -228,8 +228,8 @@ class Transaction:
|
|||
self._complete_read()
|
||||
self._read_header()
|
||||
return self
|
||||
except:
|
||||
raise StopIteration()
|
||||
except Exception as e:
|
||||
raise StopIteration() from e
|
||||
|
||||
|
||||
class Ledger:
|
||||
|
@ -275,7 +275,7 @@ class Ledger:
|
|||
self._current_tx = Transaction(self._filenames[self._fileindex])
|
||||
return next(self._current_tx)
|
||||
else:
|
||||
raise StopIteration()
|
||||
raise
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
|
|
@ -127,7 +127,9 @@ def run_to_destruction(args):
|
|||
break
|
||||
|
||||
if time.time() > end_time:
|
||||
raise TimeoutError(f"Node took longer than {timeout}s to terminate")
|
||||
raise TimeoutError(
|
||||
f"Node took longer than {timeout}s to terminate"
|
||||
) from e
|
||||
|
||||
network.ignore_errors_on_shutdown()
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ def run(args):
|
|||
for choice in args.test_suite:
|
||||
try:
|
||||
chosen_suite.extend(s.suites[choice])
|
||||
except KeyError:
|
||||
raise ValueError(f"Unhandled choice: {choice}")
|
||||
except KeyError as e:
|
||||
raise ValueError(f"Unhandled choice: {choice}") from e
|
||||
|
||||
seed = None
|
||||
if os.getenv("SHUFFLE_SUITE"):
|
||||
|
|
|
@ -432,7 +432,7 @@ class Network:
|
|||
else infra.node.NodeStatus.TRUSTED
|
||||
),
|
||||
)
|
||||
except TimeoutError:
|
||||
except TimeoutError as e:
|
||||
# The node can be safely discarded since it has not been
|
||||
# attributed a unique node_id by CCF
|
||||
LOG.error(f"New pending node {new_node.node_id} failed to join the network")
|
||||
|
@ -442,7 +442,7 @@ class Network:
|
|||
# Throw accurate exceptions if known errors found in
|
||||
for error in errors:
|
||||
if "CODE_ID_NOT_FOUND" in error:
|
||||
raise CodeIdNotFound
|
||||
raise CodeIdNotFound from e
|
||||
raise
|
||||
|
||||
return new_node
|
||||
|
|
|
@ -244,8 +244,8 @@ class Node:
|
|||
assert (
|
||||
rep.status_code == 200
|
||||
), f"An error occured after node {self.node_id} joined the network: {rep.body}"
|
||||
except ccf.clients.CCFConnectionException:
|
||||
raise TimeoutError(f"Node {self.node_id} failed to join the network")
|
||||
except ccf.clients.CCFConnectionException as e:
|
||||
raise TimeoutError(f"Node {self.node_id} failed to join the network") from e
|
||||
|
||||
def get_ledger(self):
|
||||
return self.remote.get_ledger()
|
||||
|
|
|
@ -38,7 +38,7 @@ def ensure_reqs(check_reqs):
|
|||
except Exception as e:
|
||||
raise TestRequirementsNotMet(
|
||||
f"Could not check if test requirements were met: {e}"
|
||||
)
|
||||
) from e
|
||||
|
||||
return func(network, args, *nargs, **kwargs)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче